diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-20 15:39:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-20 15:39:10 -0700 |
commit | c6fbbbc17440b6629fc41fef1a6fc80a1830f982 (patch) | |
tree | 78090bddc1f3f90d56b3459578bd43b30b2c9e80 /activerecord/lib/active_record/associations/preloader/association.rb | |
parent | 18dccdccf75e4084718622f578a1ff98f2da6955 (diff) | |
download | rails-c6fbbbc17440b6629fc41fef1a6fc80a1830f982.tar.gz rails-c6fbbbc17440b6629fc41fef1a6fc80a1830f982.tar.bz2 rails-c6fbbbc17440b6629fc41fef1a6fc80a1830f982.zip |
push `run` up to preload
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader/association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 051bc3a8da..9b8750b9ea 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -72,6 +72,12 @@ module ActiveRecord end def target_records + associated_records_by_owner.values.flatten + end + + private + + def lhs_records return @target_records if @target_records owners_map = owners_by_key @@ -85,8 +91,6 @@ module ActiveRecord } end - private - def associated_records_by_owner owners_map = owners_by_key owner_keys = owners_map.keys.compact @@ -98,7 +102,7 @@ module ActiveRecord # Some databases impose a limit on the number of ids in a list (in Oracle it's 1000) # Make several smaller queries if necessary or make one query if the adapter supports it caster = type_caster - target_records.each do |record| + lhs_records.each do |record| owner_key = caster.call record[association_key_name] owners_map[owner_key].each do |owner| |