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/connection_adapters | |
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/connection_adapters')
3 files changed, 7 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 83e64d3c43..d8bd33f72a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -310,12 +310,10 @@ module ActiveRecord # on mysql (even when aliasing the tables), but mysql allows using JOIN directly in # an UPDATE statement, so in the mysql adapters we redefine this to do that. def join_to_update(update, select) #:nodoc: - subselect = select.clone - subselect.ast.cores.last.projections = [update.ast.key] + subselect = select.ast.clone + subselect.cores.last.projections = [update.ast.key] - update.ast.limit = nil - update.ast.orders = [] - update.wheres = [update.ast.key.in(subselect)] + update.where update.ast.key.in(subselect) end protected diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index 172d08b6f4..41d410e062 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -594,11 +594,10 @@ module ActiveRecord subselect = Arel::SelectManager.new(select.engine, subsubselect) subselect.project(Arel::Table.new('__active_record_temp')[update.ast.key.name]) - update.ast.limit = nil - update.ast.orders = [] - update.wheres = [update.ast.key.in(subselect)] + update.where update.ast.key.in(subselect) else update.table select.ast.cores.last.source + update.wheres = select.constraints end end diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index bd6cb2d3b8..d4aaf26bf3 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -508,11 +508,10 @@ module ActiveRecord subselect = Arel::SelectManager.new(select.engine, subsubselect) subselect.project(Arel::Table.new('__active_record_temp')[update.ast.key.name]) - update.ast.limit = nil - update.ast.orders = [] - update.wheres = [update.ast.key.in(subselect)] + update.where update.ast.key.in(subselect) else update.table select.ast.cores.last.source + update.wheres = select.constraints end end |