diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-24 06:30:59 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-04-24 13:35:42 +0900 |
commit | 5d858b5d3e5539ede0ea541a8e14126a3ee30800 (patch) | |
tree | 6902aaec7f9e8e6053949b94b96597bb16331005 /activerecord/lib/active_record/associations/preloader | |
parent | 2c0729d8cb13100ea576337ebb7703320203c548 (diff) | |
download | rails-5d858b5d3e5539ede0ea541a8e14126a3ee30800.tar.gz rails-5d858b5d3e5539ede0ea541a8e14126a3ee30800.tar.bz2 rails-5d858b5d3e5539ede0ea541a8e14126a3ee30800.zip |
Fix sliced IN clauses to be grouped
Follow up of #35838.
And also this refactors `in_clause_length` handling is entirely
integrated in Arel visitor.
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 46532f651e..342d9e7a5a 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -36,13 +36,7 @@ module ActiveRecord def preloaded_records return @preloaded_records if defined?(@preloaded_records) - return [] if owner_keys.empty? - # 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 - slices = owner_keys.each_slice(klass.connection.in_clause_length || owner_keys.size) - @preloaded_records = slices.flat_map do |slice| - records_for(slice) - end + @preloaded_records = owner_keys.empty? ? [] : records_for(owner_keys) end private |