mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make "not" apply to the whole sub-expression when generating sql.
This commit is contained in:
parent
e4ea62bdec
commit
4bec8c8e9e
2 changed files with 8 additions and 2 deletions
|
@ -221,7 +221,7 @@ module Arel
|
|||
end
|
||||
|
||||
def visit_Arel_Nodes_Not o
|
||||
"NOT #{visit o.expr}"
|
||||
"NOT (#{visit o.expr})"
|
||||
end
|
||||
|
||||
def visit_Arel_Table o
|
||||
|
|
|
@ -40,7 +40,13 @@ module Arel
|
|||
|
||||
it "should visit_Not" do
|
||||
sql = @visitor.accept Nodes::Not.new(Arel.sql("foo"))
|
||||
sql.must_be_like "NOT foo"
|
||||
sql.must_be_like "NOT (foo)"
|
||||
end
|
||||
|
||||
it "should apply Not to the whole expression" do
|
||||
node = Nodes::And.new @attr.eq(10), @attr.eq(11)
|
||||
sql = @visitor.accept Nodes::Not.new(node)
|
||||
sql.must_be_like %{NOT ("users"."id" = 10 AND "users"."id" = 11)}
|
||||
end
|
||||
|
||||
it "should visit_As" do
|
||||
|
|
Loading…
Reference in a new issue