diff options
Diffstat (limited to 'test/attributes/test_attribute.rb')
-rw-r--r-- | test/attributes/test_attribute.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/attributes/test_attribute.rb b/test/attributes/test_attribute.rb index 145da98968..38ee189a46 100644 --- a/test/attributes/test_attribute.rb +++ b/test/attributes/test_attribute.rb @@ -74,6 +74,17 @@ module Arel SELECT "users"."id" FROM "users" WHERE "users"."id" > 10 } end + + it 'should handle comparing with a subquery' do + users = Table.new(:users) + + avg = users.project(users[:karma].average) + mgr = users.project(Arel.star).where(users[:karma].gt(avg)) + + mgr.to_sql.must_be_like %{ + SELECT * FROM "users" WHERE "users"."karma" > (SELECT AVG("users"."karma") AS avg_id FROM "users") + } + end end describe '#gt_any' do |