From b4e6e47471ef951fe134a74cf71544c10a8638f5 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Fri, 26 Dec 2014 16:56:24 -0700 Subject: We don't need to type cast the offset in `find_in_batches` Part of the larger refactoring to remove type casting from Arel. We can inform it that we already have the right type by wrapping the value in an `Arel::Nodes::Quoted`. This commit can be reverted when we have removed type casting from Arel in Rail 5.1 --- activerecord/lib/active_record/relation/batches.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb index 4f0502ae75..ac13b37dce 100644 --- a/activerecord/lib/active_record/relation/batches.rb +++ b/activerecord/lib/active_record/relation/batches.rb @@ -125,7 +125,11 @@ module ActiveRecord break if records_size < batch_size - records = relation.where(table[primary_key].gt(primary_key_offset)).to_a + # FIXME: Remove this when type casting is removed from Arel + # (Rails 5.1). We can pass the offset directly instead. + quoted_offset = Arel::Nodes::Quoted.new(primary_key_offset) + + records = relation.where(table[primary_key].gt(quoted_offset)).to_a end end -- cgit v1.2.3