diff options
Diffstat (limited to 'test/visitors/test_to_sql.rb')
-rw-r--r-- | test/visitors/test_to_sql.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb index 09f037f75f..c49d2a6bdf 100644 --- a/test/visitors/test_to_sql.rb +++ b/test/visitors/test_to_sql.rb @@ -143,6 +143,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 @@ -191,6 +200,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 |