aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-03-26 10:06:13 -0400
committereileencodes <eileencodes@gmail.com>2014-03-31 19:28:44 -0400
commite247f3257927e008ed89944249ac38a8838f719f (patch)
tree56bd8a9a7d273a648c80719773fe0f4346310042 /activerecord/test/cases/associations
parenta116afe5365dfaa3e5f98749f98090872c7aaecc (diff)
downloadrails-e247f3257927e008ed89944249ac38a8838f719f.tar.gz
rails-e247f3257927e008ed89944249ac38a8838f719f.tar.bz2
rails-e247f3257927e008ed89944249ac38a8838f719f.zip
fix delete_all to remove records directly
When delete_all is run on a CollectionProxy and has a dependency of delete_all the SQL that is produced has an IN statement. (DELETE FROM `associated_model` where `associated_model` .`parent_id` = 1 AND `associated_model`.`id` IN (1, 2, 3...)). This only happens if the association is not loaded (both loaded and non-loaded delete_all should behave the same. This is a huge problem when it comes to deleting many records because the query becomes very slow. Instead the SQL produced should be (DELETE FROM `assoicated_model` where `associated_model`.`parent_model_id`=1). I fixed this by making sure the check for loaded and destroy also makes sure that the dependent is not delete_all, so the conditional goes to the else and deletes the records directly without the IN statement.
Diffstat (limited to 'activerecord/test/cases/associations')
0 files changed, 0 insertions, 0 deletions