diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-10-20 19:01:45 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-11-19 19:08:57 -0300 |
commit | 024bc70bfe2aa9584ecd67246d85787901362c4e (patch) | |
tree | 65a8d7dcddc07de2ab3f8989a02959818155e322 /activerecord | |
parent | 4a0a1605cdee91bb8c9d3c1cb5989efa550a3816 (diff) | |
download | rails-024bc70bfe2aa9584ecd67246d85787901362c4e.tar.gz rails-024bc70bfe2aa9584ecd67246d85787901362c4e.tar.bz2 rails-024bc70bfe2aa9584ecd67246d85787901362c4e.zip |
Added method to IM to remove objects by class and id. Then used it to remove objects when updating counters.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/counter_cache.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/identity_map.rb | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index ed0d4aef7f..d48ff92b6c 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -73,6 +73,8 @@ module ActiveRecord "#{quoted_column} = COALESCE(#{quoted_column}, 0) #{operator} #{value.abs}" end + IdentityMap.remove_by_id(symbolized_base_class, id) if IdentityMap.enabled? + update_all(updates.join(', '), primary_key => id ) end diff --git a/activerecord/lib/active_record/identity_map.rb b/activerecord/lib/active_record/identity_map.rb index 30a2a1eb0f..7eb792fec4 100644 --- a/activerecord/lib/active_record/identity_map.rb +++ b/activerecord/lib/active_record/identity_map.rb @@ -59,6 +59,10 @@ module ActiveRecord repository[record.class.symbolized_base_class].delete(record.id) end + def remove_by_id(symbolized_base_class, id) + repository[symbolized_base_class].delete(id) + end + def clear repository.clear end |