File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -453,6 +453,16 @@ func (b *SelectBuilder) ForUpdate() *SelectBuilder {
453453 return b
454454}
455455
456+ func (b * SelectBuilder ) ForUpdateNoWait () * SelectBuilder {
457+ b .Select .Lock = " FOR UPDATE NOWAIT"
458+ return b
459+ }
460+
461+ func (b * SelectBuilder ) ForUpdateSkipLocked () * SelectBuilder {
462+ b .Select .Lock = " FOR UPDATE SKIP LOCKED"
463+ return b
464+ }
465+
456466// WithSharedLock sets the LOCK IN SHARE MODE tag on the statement
457467// causing the result rows to be read locked (dependent on the
458468// specific MySQL storage engine).
Original file line number Diff line number Diff line change @@ -491,6 +491,10 @@ func TestSelectBuilder(t *testing.T) {
491491 "SELECT DISTINCT * FROM `users`" },
492492 {users .Select ("*" ).ForUpdate (),
493493 "SELECT * FROM `users` FOR UPDATE" },
494+ {users .Select ("*" ).ForUpdateNoWait (),
495+ "SELECT * FROM `users` FOR UPDATE NOWAIT" },
496+ {users .Select ("*" ).ForUpdateSkipLocked (),
497+ "SELECT * FROM `users` FOR UPDATE SKIP LOCKED" },
494498 {users .Select ("*" ).WithSharedLock (),
495499 "SELECT * FROM `users` LOCK IN SHARE MODE" },
496500 {users .Select ("*" ).Comments ([]string {"quux" , "quuz" }),
You can’t perform that action at this time.
0 commit comments