khiav223577 / deep_pluck

Allow you to pluck attributes from nested associations without loading a bunch of records.
MIT License
460 stars 14 forks source link

Fix: deep_pluck at has_many association with primary_key options will fail #56

Closed khiav223577 closed 1 year ago

khiav223577 commented 1 year ago

The error messages:

1) Error:
  DeepPluckPrimaryKeyTest#test_species:
NoMethodError: undefined method `[]' for nil:NilClass
    xxxxx/deep_pluck/lib/deep_pluck/data_combiner.rb:32:in `block in assign_values_to_parent'
    xxxxx/deep_pluck/lib/deep_pluck/data_combiner.rb:27:in `each'
xxxxx/deep_pluck/lib/deep_pluck/data_combiner.rb:27:in `assign_values_to_parent'
    xxxxx/deep_pluck/lib/deep_pluck/data_combiner.rb:8:in `combine_data'
    xxxxx/deep_pluck/lib/deep_pluck/model.rb:153:in `set_includes_data'
xxxxx/deep_pluck/lib/deep_pluck/model.rb:199:in `block in load_data'
    xxxxx/deep_pluck/lib/deep_pluck/model.rb:198:in `each'
    xxxxx/deep_pluck/lib/deep_pluck/model.rb:198:in `load_data'
xxxxx/deep_pluck/lib/deep_pluck/model.rb:206:in `load_all'
    xxxxx/deep_pluck/lib/deep_pluck.rb:8:in `deep_pluck'
    xxxxx/deep_pluck/test/deep_pluck_primary_key_test.rb:12:in `test_species'