aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/collection_association.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-04-28 19:09:46 -0400
committereileencodes <eileencodes@gmail.com>2014-04-28 19:09:46 -0400
commitfe5d0988241cf34a378f05ce84e90c5d0636287a (patch)
treed5dbc361fd3c3925bdb260d346bffc31eed2b429 /activerecord/lib/active_record/associations/collection_association.rb
parent7707eb9e75587d655916645ad633cd6d45c40c03 (diff)
downloadrails-fe5d0988241cf34a378f05ce84e90c5d0636287a.tar.gz
rails-fe5d0988241cf34a378f05ce84e90c5d0636287a.tar.bz2
rails-fe5d0988241cf34a378f05ce84e90c5d0636287a.zip
flip conditional in delete_all to handle nullify better
Nullify (or nil dependency) was doing the same thing delete_all was doing in issue #14546, creating a large IN statement if the association was loaded. Loaded and not loaded associations should behave the same. The IN statement is also not great because it's inefficient.
Diffstat (limited to 'activerecord/lib/active_record/associations/collection_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/collection_association.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb
index 9bf253d976..1c84973920 100644
--- a/activerecord/lib/active_record/associations/collection_association.rb
+++ b/activerecord/lib/active_record/associations/collection_association.rb
@@ -252,10 +252,10 @@ module ActiveRecord
end
def delete_all_with_dependency(dependent)
- if dependent == :delete_all
- delete_records(:all, dependent)
- else
+ if dependent == :destroy
delete_or_destroy(load_target, dependent)
+ else
+ delete_records(:all, dependent)
end
end