diff options
author | thedarkone <thedarkone2@gmail.com> | 2011-07-26 12:35:41 +0200 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2011-07-26 12:35:41 +0200 |
commit | 75a78b3496d4d7dbba3675b2d66250408b4efcf5 (patch) | |
tree | 9dda8414d4fd8b2415b957d7b6f7c6fbec7fc962 /lib/arel/visitors | |
parent | 593002080cbcbb6e14acf3bc909aab819811f215 (diff) | |
download | rails-75a78b3496d4d7dbba3675b2d66250408b4efcf5.tar.gz rails-75a78b3496d4d7dbba3675b2d66250408b4efcf5.tar.bz2 rails-75a78b3496d4d7dbba3675b2d66250408b4efcf5.zip |
Oracle does not allow ORDER BY/LIMIT in UPDATE queries.
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/oracle.rb | 12 |
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 |