Skip to content
Browse files

Oracle does not allow ORDER BY/LIMIT in UPDATE queries.

  • Loading branch information...
1 parent 5930020 commit 75a78b3496d4d7dbba3675b2d66250408b4efcf5 @thedarkone thedarkone committed Jul 26, 2011
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/arel/visitors/oracle.rb
View
12 lib/arel/visitors/oracle.rb
@@ -65,6 +65,18 @@ def visit_Arel_Nodes_Except o
"( #{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

0 comments on commit 75a78b3

Please sign in to comment.
Something went wrong with that request. Please try again.