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

Mention Arel.sql in update_all docs [docs] #45662

Merged
merged 1 commit into from
Jul 26, 2022
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
6 changes: 5 additions & 1 deletion activerecord/lib/active_record/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ def _exec_scope(...) # :nodoc:
#
# ==== Parameters
#
# * +updates+ - A string, array, or hash representing the SET part of an SQL statement.
# * +updates+ - A string, array, or hash representing the SET part of an SQL statement. Any strings provided will
# be type cast, unless you use `Arel.sql`. (Don't pass user-provided values to `Arel.sql`.)
#
# ==== Examples
#
Expand All @@ -463,6 +464,9 @@ def _exec_scope(...) # :nodoc:
#
# # Update all invoices and set the number column to its id value.
# Invoice.update_all('number = id')
#
# # Update all books with 'Rails' in their title
# Book.where('title LIKE ?', '%Rails%').update_all(title: Arel.sql("title + ' - volume 1'"))
def update_all(updates)
raise ArgumentError, "Empty list of attributes to change" if updates.blank?

Expand Down