diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-24 14:56:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-24 14:56:16 -0700 |
commit | 6420041b88bc16d8f838815185b4d004907b837e (patch) | |
tree | 37b0033afa58ed2da26df128d34e700251556db0 /lib/arel/visitors | |
parent | aa6a82617178698f4f5083cc8ba08d2f761583af (diff) | |
download | rails-6420041b88bc16d8f838815185b4d004907b837e.tar.gz rails-6420041b88bc16d8f838815185b4d004907b837e.tar.bz2 rails-6420041b88bc16d8f838815185b4d004907b837e.zip |
fixing formatting
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/oracle.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb index 360715f307..8d6c15f37d 100644 --- a/lib/arel/visitors/oracle.rb +++ b/lib/arel/visitors/oracle.rb @@ -4,7 +4,7 @@ module Arel private def visit_Arel_Nodes_SelectStatement o - order_hacks(o) + o = order_hacks(o) if o.limit && o.orders.empty? && !o.offset o.cores.last.wheres.push Nodes::LessThanOrEqual.new( @@ -15,10 +15,10 @@ module Arel end if o.limit && o.offset - o = o.dup - limit = o.limit.to_i - offset = o.offset - o.limit = nil + o = o.dup + limit = o.limit.to_i + offset = o.offset + o.limit = nil o.offset = nil sql = super(o) return <<-eosql @@ -32,8 +32,8 @@ module Arel end if o.limit && !o.orders.empty? - o = o.dup - limit = o.limit + o = o.dup + limit = o.limit o.limit = nil return "SELECT * FROM (#{super(o)}) WHERE ROWNUM <= #{limit}" end @@ -48,18 +48,19 @@ module Arel ### # Hacks for the order clauses specific to Oracle def order_hacks o - return if o.orders.empty? - return unless o.cores.any? do |core| + return o if o.orders.empty? + return o unless o.cores.any? do |core| core.projections.any? do |projection| /DISTINCT.*FIRST_VALUE/ === projection end end - orders = o.orders + orders = o.orders o.orders = [] orders.each_with_index do |order, i| o.orders << Nodes::SqlLiteral.new("alias_#{i}__ #{'DESC' if /\bdesc$/i === order}") end + o end end end |