aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-12-07 08:53:24 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-12-07 08:56:49 -0200
commit89ab303d8b78a73cb7d306a026f185986f44aa2a (patch)
treec5aa40d2f36e15c775be42a11672f1011302b815 /activerecord/lib/active_record/relation
parentee5999d14015782ee06a9d03ff4c2f007a52ac66 (diff)
downloadrails-89ab303d8b78a73cb7d306a026f185986f44aa2a.tar.gz
rails-89ab303d8b78a73cb7d306a026f185986f44aa2a.tar.bz2
rails-89ab303d8b78a73cb7d306a026f185986f44aa2a.zip
Fix where.not with in clause
Arel::Nodes::In inherits from Arel::Nodes::Equality, so the case statement was always using the Equality operator for both scenarios, resulting in a not equal query instead.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index ad9ed98382..d3a13c8e2f 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -20,15 +20,15 @@ module ActiveRecord
# User.where.not(name: nil)
# # SELECT * FROM users WHERE name IS NOT NULL
#
- # User.where.not(name: %(Ko1 Nobu))
+ # User.where.not(name: %w(Ko1 Nobu))
# # SELECT * FROM users WHERE name NOT IN ('Ko1', 'Nobu')
def not(opts, *rest)
where_value = @scope.send(:build_where, opts, rest).map do |rel|
case rel
- when Arel::Nodes::Equality
- Arel::Nodes::NotEqual.new(rel.left, rel.right)
when Arel::Nodes::In
Arel::Nodes::NotIn.new(rel.left, rel.right)
+ when Arel::Nodes::Equality
+ Arel::Nodes::NotEqual.new(rel.left, rel.right)
when String
Arel::Nodes::Not.new(Arel::Nodes::SqlLiteral.new(rel))
else