From 75a78b3496d4d7dbba3675b2d66250408b4efcf5 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Tue, 26 Jul 2011 12:35:41 +0200 Subject: Oracle does not allow ORDER BY/LIMIT in UPDATE queries. --- lib/arel/visitors/oracle.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/arel') 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 -- cgit v1.2.3