aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-08-18 10:15:26 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-08-18 10:15:26 -0300
commit0dfb8ff347b3ca72dda24ccb1edc75b46df98668 (patch)
tree0c6d33e9ec0560229c0be6f06cd6d6e6c3cab094 /activerecord
parent7d0b69d916b46218524c7fe8fdb6a1d0b20caefe (diff)
downloadrails-0dfb8ff347b3ca72dda24ccb1edc75b46df98668.tar.gz
rails-0dfb8ff347b3ca72dda24ccb1edc75b46df98668.tar.bz2
rails-0dfb8ff347b3ca72dda24ccb1edc75b46df98668.zip
Use COALESCE in update_counters docs to reflect the implementation
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/counter_cache.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 237cd56683..ed0d4aef7f 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -56,15 +56,15 @@ module ActiveRecord
# Post.update_counters 5, :comment_count => -1, :action_count => 1
# # Executes the following SQL:
# # UPDATE posts
- # # SET comment_count = comment_count - 1,
- # # action_count = action_count + 1
+ # # SET comment_count = COALESCE(comment_count, 0) - 1,
+ # # action_count = COALESCE(action_count, 0) + 1
# # WHERE id = 5
#
# # For the Posts with id of 10 and 15, increment the comment_count by 1
# Post.update_counters [10, 15], :comment_count => 1
# # Executes the following SQL:
# # UPDATE posts
- # # SET comment_count = comment_count + 1,
+ # # SET comment_count = COALESCE(comment_count, 0) + 1,
# # WHERE id IN (10, 15)
def update_counters(id, counters)
updates = counters.map do |counter_name, value|