Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example on concatenating multiple faker generators? #1

Open
zanhsieh opened this issue Feb 19, 2020 · 2 comments
Open

Example on concatenating multiple faker generators? #1

zanhsieh opened this issue Feb 19, 2020 · 2 comments

Comments

@zanhsieh
Copy link

zanhsieh commented Feb 19, 2020

Hi,

Just wonder what should the right syntax for concatenating multiple faker generators.

I tried this on my mask.yml

version: 1
db_url: mongodb://mongodb:27017/development
models:
  - name: users
    fields:
      emailAddress: "\"%s.%s\" % [FFaker::Name.unique.first_name, FFaker::Name.unique.last_name]

But it returns error:

Masking users (475/18288)
Can't mask users

Traceback (most recent call last):
	29: from /usr/local/bundle/bin/mongo_masker:23:in `<main>'
	28: from /usr/local/bundle/bin/mongo_masker:23:in `load'
	27: from /usr/local/bundle/gems/mongo_masker-1.0.2/bin/mongo_masker:16:in `<top (required)>'
	26: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
	25: from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	24: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	23: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	22: from /usr/local/bundle/gems/mongo_masker-1.0.2/bin/mongo_masker:12:in `mask'
	21: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:22:in `mask'
	20: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:42:in `track_time'
	19: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:23:in `block in mask'
	18: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:23:in `each'
	17: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:24:in `block (2 levels) in mask'
	16: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:58:in `mask_document'
	15: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:75:in `mask_each_document'
	14: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:75:in `each_with_index'
	13: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/collection/view/iterable.rb:50:in `each'
	12: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/cursor.rb:152:in `each'
	11: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/cursor.rb:152:in `loop'
	10: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/cursor.rb:154:in `block in each'
	 9: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/collection/view/iterable.rb:51:in `block in each'
	 8: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:77:in `block in mask_each_document'
	 7: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:112:in `create_mask'
	 6: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:112:in `each'
	 5: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:119:in `block in create_mask'
	 4: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:132:in `evalute_field_value'
	 3: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:132:in `eval'
	 2: from (eval):1:in `evalute_field_value'
	 1: from /usr/local/bundle/gems/ffaker-2.13.0/lib/ffaker/utils/unique_utils.rb:14:in `method_missing'
/usr/local/bundle/gems/ffaker-2.13.0/lib/ffaker/utils/unique_utils.rb:42:in `add_results_to_hash': FFaker::UniqueUtils::RetryLimitExceeded (FFaker::UniqueUtils::RetryLimitExceeded)
	26: from /usr/local/bundle/bin/mongo_masker:23:in `<main>'
	25: from /usr/local/bundle/bin/mongo_masker:23:in `load'
	24: from /usr/local/bundle/gems/mongo_masker-1.0.2/bin/mongo_masker:16:in `<top (required)>'
	23: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
	22: from /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
	21: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
	20: from /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
	19: from /usr/local/bundle/gems/mongo_masker-1.0.2/bin/mongo_masker:12:in `mask'
	18: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:22:in `mask'
	17: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:42:in `track_time'
	16: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:23:in `block in mask'
	15: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:23:in `each'
	14: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:24:in `block (2 levels) in mask'
	13: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:58:in `mask_document'
	12: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:75:in `mask_each_document'
	11: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:75:in `each_with_index'
	10: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/collection/view/iterable.rb:50:in `each'
	 9: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/cursor.rb:152:in `each'
	 8: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/cursor.rb:152:in `loop'
	 7: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/cursor.rb:154:in `block in each'
	 6: from /usr/local/bundle/gems/mongo-2.11.2/lib/mongo/collection/view/iterable.rb:51:in `block in each'
	 5: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:77:in `block in mask_each_document'
	 4: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:112:in `create_mask'
	 3: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:112:in `each'
	 2: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:119:in `block in create_mask'
	 1: from /usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:131:in `evalute_field_value'
/usr/local/bundle/gems/mongo_masker-1.0.2/lib/mongo_masker.rb:134:in `rescue in evalute_field_value': Can't eval `"%s.%s" % [FFaker::Name.unique.first_name, FFaker::Name.unique.last_name]` (RuntimeError)

Also, tried following in mask.yml but having similar errors.

"FFaker::Name.unique.first_name+\".\"+FFaker::Name.unique.last_name"
FFaker::Name.unique.first_name+'.'+FFaker::Name.unique.last_name
"Kernal::format(\"%s.%s\", FFaker::Name.unique.first_name, FFaker::Name.unique.first_name)"
FFaker::Name.unique.first_name.concat('.').concat(FFaker::Name.unique.last_name)

Please advice.

@zanhsieh
Copy link
Author

/assign @yuyuvn

@hirokipf
Copy link
Contributor

I think you can concat them in the following way.

emailAddress: "FFaker::Name.unique.first_name + '.' + FFaker::Name.unique.last_name"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants