Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CounterCache: Normalize example counter column names. #48082

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions activerecord/lib/active_record/counter_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,28 @@ def reset_counters(id, *counters, touch: nil)
#
# ==== Examples
#
# # For the Post with id of 5, decrement the comment_count by 1, and
# # increment the action_count by 1
# Post.update_counters 5, comment_count: -1, action_count: 1
# # For the Post with id of 5, decrement the comments_count by 1, and
# # increment the actions_count by 1
# Post.update_counters 5, comments_count: -1, actions_count: 1
# # Executes the following SQL:
# # UPDATE posts
# # SET comment_count = COALESCE(comment_count, 0) - 1,
# # action_count = COALESCE(action_count, 0) + 1
# # SET comments_count = COALESCE(comments_count, 0) - 1,
# # actions_count = COALESCE(actions_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
# # For the Posts with id of 10 and 15, increment the comments_count by 1
# Post.update_counters [10, 15], comments_count: 1
# # Executes the following SQL:
# # UPDATE posts
# # SET comment_count = COALESCE(comment_count, 0) + 1
# # SET comments_count = COALESCE(comments_count, 0) + 1
# # WHERE id IN (10, 15)
#
# # For the Posts with id of 10 and 15, increment the comment_count by 1
# # For the Posts with id of 10 and 15, increment the comments_count by 1
# # and update the updated_at value for each counter.
# Post.update_counters [10, 15], comment_count: 1, touch: true
# Post.update_counters [10, 15], comments_count: 1, touch: true
# # Executes the following SQL:
# # UPDATE posts
# # SET comment_count = COALESCE(comment_count, 0) + 1,
# # SET comments_count = COALESCE(comments_count, 0) + 1,
# # `updated_at` = '2016-10-13T09:59:23-05:00'
# # WHERE id IN (10, 15)
def update_counters(id, counters)
Expand Down