From 5d858b5d3e5539ede0ea541a8e14126a3ee30800 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 24 Apr 2019 06:30:59 +0900 Subject: 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. --- .../lib/active_record/associations/preloader/association.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'activerecord/lib/active_record/associations/preloader') 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 -- cgit v1.2.3