1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

tests for passing a subquery to #in and #not_in

This commit is contained in:
Sven Fuchs 2010-12-07 10:05:25 +01:00
parent 4bec8c8e9e
commit 54d62de817

View file

@ -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