Skip to content

Instance Method

lockingClause(_:)

Adds a locking clause to this query. If called more than once, the last call wins.
@discardableResult func lockingClause(_ lockingClause: any SQLExpression) -> Self

Discussion

db.select()...lockingClause(...)

Also referred to as locking or “consistent” reads, the locking clause syntax locks all selected rows for the duration of the current transaction with a type of lock determined by the specific locking clause and the underlying database’s support for this construct.

Note

This method allows providing an arbitrary SQL expression as the locking clause.

Warning

If the database in use does not support locking reads, the locking clause will be silently ignored regardless of its value.