aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/counter_cache.rb
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2017-01-14 19:00:07 +0100
committerGitHub <noreply@github.com>2017-01-14 19:00:07 +0100
commit31a95eda42e2111c1d8b02733901992fb340d0af (patch)
tree64825155eb802955fce8b289cd017554eba611ba /activerecord/lib/active_record/counter_cache.rb
parenta3afd0538462aa49e5585c251c65f8de106f1c07 (diff)
parentbad9bfbea6d6af9dc28583e08a49492668087393 (diff)
downloadrails-31a95eda42e2111c1d8b02733901992fb340d0af.tar.gz
rails-31a95eda42e2111c1d8b02733901992fb340d0af.tar.bz2
rails-31a95eda42e2111c1d8b02733901992fb340d0af.zip
Merge pull request #27660 from akihiro17/updates-timestamp
Add the touch option to ActiveRecord#increment! and decrement!
Diffstat (limited to 'activerecord/lib/active_record/counter_cache.rb')
-rw-r--r--activerecord/lib/active_record/counter_cache.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 93b9371206..cbd71a3779 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -105,7 +105,8 @@ module ActiveRecord
end
if touch
- updates << sanitize_sql_for_assignment(touch_updates(touch))
+ touch_updates = touch_updates(touch)
+ updates << sanitize_sql_for_assignment(touch_updates) unless touch_updates.empty?
end
unscoped.where(primary_key => id).update_all updates.join(", ")