Fix `update_all`/`delete_all` to use exactly table

https://buildkite.com/rails/rails/builds/75795#4704b28c-fb6e-472b-bc40-7d3647e95292/1069-1078
This commit is contained in:
Ryuta Kamizono 2021-03-15 18:06:57 +09:00
parent cd809b3176
commit 92281b4911
1 changed files with 8 additions and 0 deletions

View File

@ -481,7 +481,11 @@ module ActiveRecord
values = Arel.sql(klass.sanitize_sql_for_assignment(updates, table.name))
end
source = arel.source.clone
source.left = table
stmt = arel.compile_update(values, table[primary_key])
stmt.table(source)
klass.connection.update(stmt, "#{klass} Update All")
end
@ -605,7 +609,11 @@ module ActiveRecord
return relation.delete_all
end
source = arel.source.clone
source.left = table
stmt = arel.compile_delete(table[primary_key])
stmt.from(source)
affected = klass.connection.delete(stmt, "#{klass} Destroy")