From 242d70278689a0f7e6c6f415992c8de0aa5caee0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 28 Aug 2013 17:54:58 -0700 Subject: remove extra flat_map array --- .../active_record/associations/preloader/association.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 3059bae76f..dbcb1e75a9 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -82,15 +82,16 @@ 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 sliced = owner_keys.each_slice(klass.connection.in_clause_length || owner_keys.size) - records = sliced.flat_map { |slice| records_for(slice) } - - records.each do |record| - owner_key = owner_id_for records, record - - owners_map[owner_key].each do |owner| - records_by_owner[owner] << record + sliced.each { |slice| + records = records_for(slice) + records.each do |record| + owner_key = owner_id_for records, record + + owners_map[owner_key].each do |owner| + records_by_owner[owner] << record + end end - end + } end records_by_owner -- cgit v1.2.3