sunitparekh/data-anonymization

error when attempting to use SelectFromDatabase field strategy

picaron opened this issue · 3 comments

I get the following error when attempting to use the SelectFromDatabase strategy :

/Users/pascal/.rvm/gems/ruby-1.9.3-p448/gems/data-anonymization-0.5.4/lib/strategy/field/string/select_from_database.rb:14:in `initialize': wrong number of arguments (2 for 3) (ArgumentError)
    from anon-reclamations.rb:49:in `new'
    from anon-reclamations.rb:49:in `block (2 levels) in <main>'
    from /Users/pascal/.rvm/gems/ruby-1.9.3-p448/gems/data-anonymization-0.5.4/lib/strategy/base.rb:24:in `instance_eval'
    from /Users/pascal/.rvm/gems/ruby-1.9.3-p448/gems/data-anonymization-0.5.4/lib/strategy/base.rb:24:in `process_fields'
    from /Users/pascal/.rvm/gems/ruby-1.9.3-p448/gems/data-anonymization-0.5.4/lib/core/database.rb:38:in `table'
    from anon-reclamations.rb:47:in `block in <main>'
    from /Users/pascal/.rvm/gems/ruby-1.9.3-p448/gems/data-anonymization-0.5.4/lib/core/dsl.rb:9:in `instance_eval'
    from /Users/pascal/.rvm/gems/ruby-1.9.3-p448/gems/data-anonymization-0.5.4/lib/core/dsl.rb:9:in `database'
    from anon-reclamations.rb:16:in `<main>'

here is the code used that generates this error :

  table 'dossiers_reclamation' do
    primary_key 'dossier_id'
    anonymize('nom_avocat_representant_assure_principal').using FieldStrategy::SelectFromDatabase.new('assures','nom_complet')
    anonymize('nom_avocat_representant_reclamant_principal').using FieldStrategy::SelectFromDatabase.new('reclamants','nom_complet')
  end

the error message seems to indicate that a 3rd parameter is required

nevermind, the 3rd parameter is the connection_spec ... it was omitted in the examples

Do you think defaulting to source_db would help?

Yes it would be a sensible default 👍