mailru / dbr

Additions to Go's database/sql for super fast performance and convenience. (fork of gocraft/dbr)
MIT License
178 stars 36 forks source link

Support for "FOR UPDATE SKIP LOCKED" #30

Closed pieterclaerhout closed 3 years ago

pieterclaerhout commented 4 years ago

Is there any way to use the select builder to do something like:

SELECT *
FROM "mytable"
WHERE "state" = ? AND "queue" = ?
ORDER BY "created_on"
LIMIT 1
FOR UPDATE SKIP LOCKED

The closest I get is:

dbr.From("mytable").
    Where("state = ? and queue = ?", statusQueued, queue).
    OrderBy("created_on").
    Limit(1).
    ForUpdate()

But that misses the last (essential) part SKIP LOCKED