提交 c28fe4cb 编写于 作者: R Ryan Rempel 提交者: Aaron Patterson

Make "not" apply to the whole sub-expression when generating sql.

上级 516ae526
......@@ -192,7 +192,7 @@ def visit_Arel_Nodes_On o
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 Visitors
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册