piccolo icon indicating copy to clipboard operation
piccolo copied to clipboard

Pessimistic locking: select for update

Open Abdelhadi92 opened this issue 1 year ago • 2 comments

I need to lock an object in the database in order to prevent other transactions from modifying the same record. Within the Postgres such a lock should be done using the SELECT FOR UPDATE query.

How I can do this using Piccolo?

you can find it out in Django here and in Pony here

Abdelhadi92 avatar Feb 25 '24 10:02 Abdelhadi92

It's not currently possible, but I think it would be pretty simple to add.

We could add something like a lock_strength argument to the select method.

https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE

await MyTable.select(lock_strength='UPDATE')

I'm not certain on the best API for it yet, but something like that should work.

dantownsend avatar Feb 25 '24 22:02 dantownsend

I guess this one is an absolute must have. Any updates on it?

deliro avatar May 20 '24 07:05 deliro