aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-07-26 08:46:37 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-07-26 08:46:37 -0700
commit472c8c709c00a28091e723b095d8fbc23bf8a583 (patch)
tree6795eea38ba74f7a52740ddacd2db7d30872c066 /lib/arel/visitors
parentc750aef10c528db308ab8edcfaaca8c868231f7d (diff)
parent75a78b3496d4d7dbba3675b2d66250408b4efcf5 (diff)
downloadrails-472c8c709c00a28091e723b095d8fbc23bf8a583.tar.gz
rails-472c8c709c00a28091e723b095d8fbc23bf8a583.tar.bz2
rails-472c8c709c00a28091e723b095d8fbc23bf8a583.zip
Merge pull request #69 from thedarkone/oracle-order-by-update
Oracle does not allow ORDER BY/LIMIT in UPDATE queries
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r--lib/arel/visitors/oracle.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb
index 3beea287a6..375f7dbfe9 100644
--- a/lib/arel/visitors/oracle.rb
+++ b/lib/arel/visitors/oracle.rb
@@ -65,6 +65,18 @@ module Arel
"( #{visit o.left} MINUS #{visit o.right} )"
end
+ def visit_Arel_Nodes_UpdateStatement o
+ # Oracle does not allow ORDER BY/LIMIT in UPDATEs.
+ if o.orders.any? && o.limit.nil?
+ # However, there is no harm in silently eating the ORDER BY clause if no LIMIT has been provided,
+ # otherwise let the user deal with the error
+ o = o.dup
+ o.orders = []
+ end
+
+ super
+ end
+
###
# Hacks for the order clauses specific to Oracle
def order_hacks o