diff options
author | Diego Plentz <diego@plentz.org> | 2016-11-27 19:47:51 -0200 |
---|---|---|
committer | Diego Plentz <diego@plentz.org> | 2016-11-27 19:47:51 -0200 |
commit | 8bd7735a2c3e39b9f898769fd35393e8783e1e9d (patch) | |
tree | 290d2b8e3a1a5c6187fa81c490c00f184e1b969d /activerecord/lib/active_record | |
parent | c638d47872e50fc48cedc4dd772efcf3fefca831 (diff) | |
download | rails-8bd7735a2c3e39b9f898769fd35393e8783e1e9d.tar.gz rails-8bd7735a2c3e39b9f898769fd35393e8783e1e9d.tar.bz2 rails-8bd7735a2c3e39b9f898769fd35393e8783e1e9d.zip |
fixing update_all and delete_all when chained with left_joins. fixes #27192
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 6f602e4a23..4e941cf2df 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -373,7 +373,7 @@ module ActiveRecord stmt.set Arel.sql(@klass.send(:sanitize_sql_for_assignment, updates)) stmt.table(table) - if joins_values.any? + if has_join_values? @klass.connection.join_to_update(stmt, arel, arel_attribute(primary_key)) else stmt.key = arel_attribute(primary_key) @@ -522,7 +522,7 @@ module ActiveRecord stmt = Arel::DeleteManager.new stmt.from(table) - if joins_values.any? + if has_join_values? @klass.connection.join_to_delete(stmt, arel, arel_attribute(primary_key)) else stmt.wheres = arel.constraints @@ -680,6 +680,10 @@ module ActiveRecord private + def has_join_values? + joins_values.any? || left_outer_joins_values.any? + end + def exec_queries(&block) @records = eager_loading? ? find_with_associations.freeze : @klass.find_by_sql(arel, bound_attributes, &block).freeze |