Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pessimistic locking: select for update #932

Open
Abdelhadi92 opened this issue Feb 25, 2024 · 2 comments
Open

Pessimistic locking: select for update #932

Abdelhadi92 opened this issue Feb 25, 2024 · 2 comments

Comments

@Abdelhadi92
Copy link

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 Abdelhadi92 changed the title Pessimistic locking Pessimistic locking: select for update Feb 25, 2024
@dantownsend
Copy link
Member

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.

@deliro
Copy link

deliro commented May 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants