diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index bae291d87c..3c9fc95a0b 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -137,6 +137,15 @@ module Arel } end + it 'can handle subqueries' do + table = Table.new(:users) + subquery = table.project(:id).where(table[:name].eq('Aaron')) + node = @attr.in subquery + @visitor.accept(node).must_be_like %{ + "users"."id" IN (SELECT id FROM "users" WHERE "users"."name" = 'Aaron') + } + end + it 'uses the same column for escaping values' do @attr = Table.new(:users)[:name] visitor = Class.new(ToSql) do @@ -185,6 +194,15 @@ module Arel } end + it 'can handle subqueries' do + table = Table.new(:users) + subquery = table.project(:id).where(table[:name].eq('Aaron')) + node = @attr.not_in subquery + @visitor.accept(node).must_be_like %{ + "users"."id" NOT IN (SELECT id FROM "users" WHERE "users"."name" = 'Aaron') + } + end + it 'uses the same column for escaping values' do @attr = Table.new(:users)[:name] visitor = Class.new(ToSql) do