diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-01 15:32:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-01 15:32:24 -0500 |
commit | fd9a583cf9d3424ec2437fd7527d0ff34d309de0 (patch) | |
tree | 64536ebc3a917ed288ab3d7f1a841a86e85ce848 | |
parent | dae525eec8062bfbbe39141de448053b127d4756 (diff) | |
parent | a685a865c6a9006578cdb14a339376724c7d8987 (diff) | |
download | rails-fd9a583cf9d3424ec2437fd7527d0ff34d309de0.tar.gz rails-fd9a583cf9d3424ec2437fd7527d0ff34d309de0.tar.bz2 rails-fd9a583cf9d3424ec2437fd7527d0ff34d309de0.zip |
Merge pull request #27539 from kamipo/counter_cache_touching_improvements
Counter cache touching improvements
-rw-r--r-- | activerecord/lib/active_record/counter_cache.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb index 9355a2f7a7..020f4b872e 100644 --- a/activerecord/lib/active_record/counter_cache.rb +++ b/activerecord/lib/active_record/counter_cache.rb @@ -46,11 +46,11 @@ module ActiveRecord counter_name = reflection.counter_cache_column updates = { counter_name.to_sym => object.send(counter_association).count(:all) } + updates.merge!(touch_updates(object, touch)) if touch - unscoped.where(primary_key => object.id).update_all( - updates.merge(touch_updates(object, touch)) - ) + unscoped.where(primary_key => object.id).update_all(updates) end + return true end @@ -106,7 +106,7 @@ module ActiveRecord if touch object = find(id) - touch_updates(object, touch).map do |column, touch_time| + touch_updates(object, touch).each do |column, touch_time| updates << "#{connection.quote_column_name(column.to_s)} = #{connection.quote(touch_time)}" end end |