Merge pull request #34353 from gmcgibbon/fix_lock_docs_locking_clause

Fix example for database-specific locking clause
This commit is contained in:
Rafael França 2018-10-30 17:14:05 -04:00 committed by GitHub
commit 6b23b7e78c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -14,9 +14,9 @@ module ActiveRecord
# of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT'. Example:
#
# Account.transaction do
# # select * from accounts where name = 'shugo' limit 1 for update
# shugo = Account.where("name = 'shugo'").lock(true).first
# yuko = Account.where("name = 'yuko'").lock(true).first
# # select * from accounts where name = 'shugo' limit 1 for update nowait
# shugo = Account.lock("FOR UPDATE NOWAIT").find_by(name: "shugo")
# yuko = Account.lock("FOR UPDATE NOWAIT").find_by(name: "yuko")
# shugo.balance -= 100
# shugo.save!
# yuko.balance += 100