diff options
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/relation/where_chain_test.rb | 2 |
2 files changed, 4 insertions, 4 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 diff --git a/activerecord/test/cases/relation/where_chain_test.rb b/activerecord/test/cases/relation/where_chain_test.rb index 10b19da3fd..8409fc6571 100644 --- a/activerecord/test/cases/relation/where_chain_test.rb +++ b/activerecord/test/cases/relation/where_chain_test.rb @@ -19,7 +19,7 @@ module ActiveRecord end def test_not_in - expected = Arel::Nodes::NotEqual.new(Post.arel_table[:title], %w[hello goodbye]) + expected = Arel::Nodes::NotIn.new(Post.arel_table[:title], %w[hello goodbye]) relation = Post.where.not(title: %w[hello goodbye]) assert_equal([expected], relation.where_values) end |