diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-08-10 00:06:30 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-08-15 23:10:15 +0100 |
commit | fe0ec855419e1deba47277c96275a16ecf79bc9a (patch) | |
tree | 895f2bf111bc9e3e317d717804c48e5975dd326b /activerecord/lib/active_record/relation.rb | |
parent | 43b99f290a8070196919a68999db87873257b7b8 (diff) | |
download | rails-fe0ec855419e1deba47277c96275a16ecf79bc9a.tar.gz rails-fe0ec855419e1deba47277c96275a16ecf79bc9a.tar.bz2 rails-fe0ec855419e1deba47277c96275a16ecf79bc9a.zip |
Refactor building the update manager
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 565ece1930..15fd1a58c8 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -216,17 +216,18 @@ module ActiveRecord if conditions || options.present? where(conditions).apply_finder_options(options.slice(:limit, :order)).update_all(updates) else - stmt = arel.compile_update(Arel.sql(@klass.send(:sanitize_sql_for_assignment, updates))) + stmt = Arel::UpdateManager.new(arel.engine) + + stmt.set Arel.sql(@klass.send(:sanitize_sql_for_assignment, updates)) + stmt.table(table) stmt.key = table[primary_key] if joins_values.any? @klass.connection.join_to_update(stmt, arel) else - if limit = arel.limit - stmt.take limit - end - + stmt.take(arel.limit) stmt.order(*arel.orders) + stmt.wheres = arel.constraints end @klass.connection.update stmt, 'SQL', bind_values |