diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 10:41:06 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 10:41:06 -0800 |
commit | 6cbbbb03264bb0435cdbd589f5503baf81c67de9 (patch) | |
tree | b4b5f4d5abd2cf4c4813ce199c9d5f469b86c1c4 /test | |
parent | 05a649efeaa466dc430ea830bc6f71c6141449d9 (diff) | |
parent | 1135c2c0884bfddffa39b784d71cd3fb22bd8988 (diff) | |
download | rails-6cbbbb03264bb0435cdbd589f5503baf81c67de9.tar.gz rails-6cbbbb03264bb0435cdbd589f5503baf81c67de9.tar.bz2 rails-6cbbbb03264bb0435cdbd589f5503baf81c67de9.zip |
Merge remote branch 'sven/in-subquery' into subquery
* sven/in-subquery:
implementation for passing a subquery to #in and #not_in
tests for passing a subquery to #in and #not_in
Diffstat (limited to 'test')
-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 |