aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorthedarkone <thedarkone2@gmail.com>2011-07-25 13:30:43 +0200
committerthedarkone <thedarkone2@gmail.com>2011-07-25 13:33:44 +0200
commit10863580aa14c7456f10c1fe9b4e93fcd18e0ef8 (patch)
tree0d9b564cc80fa0272dbd01eb110fe8d820a6acfa /activerecord/lib/active_record/relation.rb
parent02691d3516e68b2de5545ec7a495024a377f89fc (diff)
downloadrails-10863580aa14c7456f10c1fe9b4e93fcd18e0ef8.tar.gz
rails-10863580aa14c7456f10c1fe9b4e93fcd18e0ef8.tar.bz2
rails-10863580aa14c7456f10c1fe9b4e93fcd18e0ef8.zip
Bring back the ability to provide :order for update_all.
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 2d0861d5c9..fff0ad1b83 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -216,17 +216,13 @@ module ActiveRecord
if conditions || options.present?
where(conditions).apply_finder_options(options.slice(:limit, :order)).update_all(updates)
else
- limit = nil
- order = []
- # Apply limit and order only if they're both present
- if @limit_value.present? == @order_values.present?
- limit = arel.limit
- order = arel.orders
+ stmt = arel.compile_update(Arel.sql(@klass.send(:sanitize_sql_for_assignment, updates)))
+
+ if limit = arel.limit
+ stmt.take limit
end
- stmt = arel.compile_update(Arel.sql(@klass.send(:sanitize_sql_for_assignment, updates)))
- stmt.take limit if limit
- stmt.order(*order)
+ stmt.order(*arel.orders)
stmt.key = table[primary_key]
@klass.connection.update stmt.to_sql, 'SQL', bind_values
end