Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:rails/arel

* 'master' of github.com:rails/arel:
  Oracle does not allow ORDER BY/LIMIT in UPDATE queries.
  • Loading branch information...
commit c9517c1b62e7d8acd5a45f72b148942ff2f549a7 2 parents 7d5ef0b + 472c8c7
@tenderlove tenderlove authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.