From fe5d0988241cf34a378f05ce84e90c5d0636287a Mon Sep 17 00:00:00 2001 From: eileencodes Date: Mon, 28 Apr 2014 19:09:46 -0400 Subject: 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. --- .../lib/active_record/associations/collection_association.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/associations/collection_association.rb') 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 -- cgit v1.2.3