aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 17:48:08 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 17:48:08 -0700
commit108df8cc90fc32ca08ff1cc86bc79ceb03ee1bfc (patch)
treeb12efe10280f45397a1467c09d2f965254c507ce /activerecord
parent50d7e448e8823ed53f7a4e8fcd12bc3cf3353cf6 (diff)
downloadrails-108df8cc90fc32ca08ff1cc86bc79ceb03ee1bfc.tar.gz
rails-108df8cc90fc32ca08ff1cc86bc79ceb03ee1bfc.tar.bz2
rails-108df8cc90fc32ca08ff1cc86bc79ceb03ee1bfc.zip
Inform Arel we don't need additional type casting 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
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/batches.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb
index 9f20db831b..f7b2167ae8 100644
--- a/activerecord/lib/active_record/relation/batches.rb
+++ b/activerecord/lib/active_record/relation/batches.rb
@@ -52,7 +52,12 @@ module ActiveRecord
end
else
enum_for :find_each, options do
- options[:start] ? where(table[primary_key].gteq(options[:start])).size : size
+ # FIXME: Remove this when type casting is removed from Arel
+ # (Rails 5.1). We can pass start directly instead.
+ if options[:start]
+ quoted_start = Arel::Nodes::Quoted.new(options[:start])
+ end
+ options[:start] ? where(table[primary_key].gteq(quoted_start)).size : size
end
end
end