aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/oracle.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-29 13:38:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-29 13:38:40 -0700
commit5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc (patch)
tree8fd01c74ec25d602c769c75d44aa3f26a65eac31 /lib/arel/visitors/oracle.rb
parentcf1db3ce28e6c9fcf6fc724f5467e6b6b450f8bf (diff)
parente619462165bfab5bee85f9761df7f48a6b8f30f0 (diff)
downloadrails-5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc.tar.gz
rails-5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc.tar.bz2
rails-5ec2fac114b1c70fe7ac87f4767b6f1cbc1e78fc.zip
Merge branch 'master' of github.com:brynary/arel
* 'master' of github.com:brynary/arel: use subquery for limit when DISTINCT is used (in Oracle) added missing require 'spec_helper' in crud_spec.rb
Diffstat (limited to 'lib/arel/visitors/oracle.rb')
-rw-r--r--lib/arel/visitors/oracle.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb
index 659b75f16d..c691ce294e 100644
--- a/lib/arel/visitors/oracle.rb
+++ b/lib/arel/visitors/oracle.rb
@@ -6,7 +6,9 @@ module Arel
def visit_Arel_Nodes_SelectStatement o
o = order_hacks(o)
- if o.limit && o.orders.empty? && !o.offset
+ # 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.projections.first !~ /^DISTINCT /
o.cores.last.wheres.push Nodes::LessThanOrEqual.new(
Nodes::SqlLiteral.new('ROWNUM'), o.limit
)
@@ -31,7 +33,7 @@ module Arel
eosql
end
- if o.limit && !o.orders.empty?
+ if o.limit
o = o.dup
limit = o.limit
o.limit = nil