diff options
-rw-r--r-- | lib/arel/visitors/depth_first.rb | 1 | ||||
-rw-r--r-- | test/attributes/test_attribute.rb | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb index 80b3c3c346..69ed345aea 100644 --- a/lib/arel/visitors/depth_first.rb +++ b/lib/arel/visitors/depth_first.rb @@ -98,7 +98,6 @@ module Arel alias :visit_Arel_Nodes_Regexp :binary alias :visit_Arel_Nodes_RightOuterJoin :binary alias :visit_Arel_Nodes_TableAlias :binary - alias :visit_Arel_Nodes_Union :binary alias :visit_Arel_Nodes_Values :binary alias :visit_Arel_Nodes_When :binary diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb index 4e55069df4..f6b73adf6a 100644 --- a/test/attributes/test_attribute.rb +++ b/test/attributes/test_attribute.rb @@ -834,6 +834,18 @@ module Arel node.must_equal Nodes::NotIn.new(attribute, mgr.ast) end + it 'can be constructed with a Union' do + relation = Table.new(:users) + mgr1 = relation.project(relation[:id]) + mgr2 = relation.project(relation[:id]) + + union = mgr1.union(mgr2) + node = relation[:id].in(union) + node.to_sql.must_be_like %{ + "users"."id" IN (( SELECT "users"."id" FROM "users" UNION SELECT "users"."id" FROM "users" )) + } + end + it 'can be constructed with a list' do attribute = Attribute.new nil, nil node = attribute.not_in([1, 2, 3]) |