Method: ActiveRecord::ConnectionAdapters::DatabaseStatements#join_to_update
- Defined in:
- lib/active_record/connection_adapters/abstract/database_statements.rb
#join_to_update(update, select, key) ⇒ Object Also known as: join_to_delete
The default strategy for an UPDATE with joins is to use a subquery. This doesn’t work 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.
355 356 357 358 359 |
# File 'lib/active_record/connection_adapters/abstract/database_statements.rb', line 355 def join_to_update(update, select, key) # :nodoc: subselect = subquery_for(key, select) update.where key.in(subselect) end |