aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-10-30 09:45:29 -0600
committerSean Griffin <sean@thoughtbot.com>2014-10-30 09:47:15 -0600
commitb6a025551910621ef8e86aba88a09161ed0a6fd3 (patch)
tree4001c36e10990da88eaa2809fa0c9679cca11535
parent7cf4d5465deb48f448000e9b484a150261e1054f (diff)
downloadrails-b6a025551910621ef8e86aba88a09161ed0a6fd3.tar.gz
rails-b6a025551910621ef8e86aba88a09161ed0a6fd3.tar.bz2
rails-b6a025551910621ef8e86aba88a09161ed0a6fd3.zip
Use `#between`, rather than `#in` for passing Ranges to Arel
Passing ranges to `#in` has been deprecated in Arel.
-rw-r--r--Gemfile1
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb2
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder/array_handler.rb2
3 files changed, 3 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile
index 1bc25a2842..6f4e91100b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,6 +14,7 @@ gem 'rack-cache', '~> 1.2'
gem 'jquery-rails', '~> 4.0.0.beta2'
gem 'coffee-rails', '~> 4.1.0'
gem 'turbolinks'
+gem 'arel', github: 'rails/arel', branch: 'master'
# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index 3df0df40ee..e4b6b49087 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -109,7 +109,7 @@ module ActiveRecord
# FIXME: I think we need to deprecate this behavior
register_handler(Class, ->(attribute, value) { attribute.eq(value.name) })
register_handler(Base, ->(attribute, value) { attribute.eq(value.id) })
- register_handler(Range, ->(attribute, value) { attribute.in(value) })
+ register_handler(Range, ->(attribute, value) { attribute.between(value) })
register_handler(Relation, RelationHandler.new)
register_handler(Array, ArrayHandler.new)
diff --git a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
index b6a9b4f63a..b8f3285c3e 100644
--- a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
@@ -32,7 +32,7 @@ module ActiveRecord
values_predicate = values_predicate.or(attribute.eq(nil))
end
- array_predicates = ranges.map { |range| attribute.in(range) }
+ array_predicates = ranges.map { |range| attribute.between(range) }
array_predicates.unshift(values_predicate)
array_predicates.inject { |composite, predicate| composite.or(predicate) }
end