From fb7532795b060fe409cbb731895ef8bd9a6449d8 Mon Sep 17 00:00:00 2001 From: Chris Dinger Date: Sat, 14 Jul 2012 00:24:09 -0500 Subject: Wrap group_by sql with a subquery for limiting rows in Oracle. Fixes #128 --- test/visitors/test_oracle.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/visitors') diff --git a/test/visitors/test_oracle.rb b/test/visitors/test_oracle.rb index 9111a266cf..29d7042084 100644 --- a/test/visitors/test_oracle.rb +++ b/test/visitors/test_oracle.rb @@ -87,6 +87,16 @@ module Arel } end + it 'creates a subquery when there is group by' do + stmt = Nodes::SelectStatement.new + stmt.cores.first.groups << Nodes::SqlLiteral.new('foo') + stmt.limit = Nodes::Limit.new(10) + sql = compile stmt + sql.must_be_like %{ + SELECT * FROM (SELECT GROUP BY foo ) WHERE ROWNUM <= 10 + } + end + it 'creates a subquery when there is DISTINCT' do stmt = Nodes::SelectStatement.new stmt.cores.first.set_quantifier = Arel::Nodes::Distinct.new -- cgit v1.2.3