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 --- lib/arel/visitors/oracle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/arel/visitors') diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb index 8a80faaa97..91f6e0223e 100644 --- a/lib/arel/visitors/oracle.rb +++ b/lib/arel/visitors/oracle.rb @@ -8,7 +8,7 @@ module Arel # if need to select first records without ORDER BY and GROUP BY and without DISTINCT # then can use simple ROWNUM in WHERE clause - if o.limit && o.orders.empty? && !o.offset && o.cores.first.set_quantifier.class.to_s !~ /Distinct/ + if o.limit && o.orders.empty? && o.cores.first.groups.empty? && !o.offset && o.cores.first.set_quantifier.class.to_s !~ /Distinct/ o.cores.last.wheres.push Nodes::LessThanOrEqual.new( Nodes::SqlLiteral.new('ROWNUM'), o.limit.expr ) -- cgit v1.2.3