diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2010-12-07 10:05:25 +0100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 10:48:18 -0800 |
commit | 1c0d8c980c3b528ce2aeb0a528590822a31b5ef2 (patch) | |
tree | dee29e5a45f8569f369a06cbc2954878824de6c0 /test/visitors/test_to_sql.rb | |
parent | c480b6fa27d0e9be910ea32deda8949f631e9d59 (diff) | |
download | rails-1c0d8c980c3b528ce2aeb0a528590822a31b5ef2.tar.gz rails-1c0d8c980c3b528ce2aeb0a528590822a31b5ef2.tar.bz2 rails-1c0d8c980c3b528ce2aeb0a528590822a31b5ef2.zip |
tests for passing a subquery to #in and #not_in
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 b9d6c78e62..e08dc89793 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 @@ -189,6 +198,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 |