diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-04 14:33:31 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-12-04 14:33:31 +0900 |
commit | 4d7354aa352b94ec3a10ad053cff04890c534080 (patch) | |
tree | acba17f5b5c2a65d61ee6dcee06d82d742491ecb /activerecord/lib/active_record/associations | |
parent | 6ca6478a67ecdff58c29d10cd408b7259ed89e2b (diff) | |
download | rails-4d7354aa352b94ec3a10ad053cff04890c534080.tar.gz rails-4d7354aa352b94ec3a10ad053cff04890c534080.tar.bz2 rails-4d7354aa352b94ec3a10ad053cff04890c534080.zip |
Ensure that `delete_all` on collection proxy returns affected count
Unlike the `Relation#delete_all`, `delete_all` on collection proxy
doesn't return affected count. Since the `CollectionProxy` is a subclass
of the `Relation`, this inconsistency is probably not intended, so it
should return the count consistently.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index e224d3456a..f6fdbcde54 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -99,6 +99,7 @@ module ActiveRecord def delete_or_nullify_all_records(method) count = delete_count(method, scope) update_counter(-count) + count end # Deletes the records according to the <tt>:dependent</tt> option. diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 2322a49931..84a9797aa5 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -161,6 +161,8 @@ module ActiveRecord else update_counter(-count) end + + count end def difference(a, b) |