mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Perf fix
If we're deleting all records in an association, don't add a IN(..) clause to the query. Fixes #3672.
This commit is contained in:
@@ -67,6 +67,11 @@
|
||||
|
||||
## Rails 3.1.3 (unreleased) ##
|
||||
|
||||
* Perf fix: If we're deleting all records in an association, don't add a IN(..) clause
|
||||
to the query. *GH 3672*
|
||||
|
||||
*Jon Leighton*
|
||||
|
||||
* Fix bug with referencing other mysql databases in set_table_name. *GH 3690*
|
||||
|
||||
* Fix performance bug with mysql databases on a server with lots of other databses. *GH 3678*
|
||||
|
||||
@@ -89,8 +89,12 @@ module ActiveRecord
|
||||
records.each { |r| r.destroy }
|
||||
update_counter(-records.length) unless inverse_updates_counter_cache?
|
||||
else
|
||||
keys = records.map { |r| r[reflection.association_primary_key] }
|
||||
scope = scoped.where(reflection.association_primary_key => keys)
|
||||
scope = scoped
|
||||
|
||||
unless records == load_target
|
||||
keys = records.map { |r| r[reflection.association_primary_key] }
|
||||
scope = scoped.where(reflection.association_primary_key => keys)
|
||||
end
|
||||
|
||||
if method == :delete_all
|
||||
update_counter(-scope.delete_all)
|
||||
|
||||
Reference in New Issue
Block a user