-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
SELECT FOR UPDATE
#8580
Comments
I just wanted to note that the above was just an example of what this type of solution could solve. I also wanted to note that .Net's Entity framework does not appear to offer any type of select for update capability. |
I would suggest to pass around a transaction object in "interactive transactions" as argument, like here: https://vincit.github.io/objection.js/guide/transactions.html#using-a-transaction
|
Here are some issues that have been closed but aren't totally resolved without better And this issue would also be avoidable with |
Hey, I will respectfully +1 since it's not been udpated in a long time. It would be great to have more updates on this since it's a core feature in many databases and makes the switch to Prisma quite harder. |
I'm having bad time trying to work around this mess with Transactionality is the prime reason to use RDBMS in the first place, and Prisma gets in the way of that... Related to #1918 |
I really hope this can be done with Prisma instead of using weird workarounds or executing a bunch of raw SQL queries, so here is my +1 for this feature 🙏 |
Problem
To avoid mid-air-collisions in REST there are two primary techniques: Last-Modified / If-Unmodified-Since, and ETags.
Prisma makes it extremely difficult to support these techniques.
There is no concept of
SELECT FOR UPDATE
, which is required to ensure that nothing issues an update underneath me while I am verifying the @updatedAt value for If-Unmodified-Since, or the hash of the select results if I am using ETags.Suggested solution
I would recommend a solution that uses a callback.
This is just one idea. It would create a transaction and use a FOR UPDATE on the SELECT if it detects an 'update' or 'delete' property.
My callback is placed in 'update.before', as to not pollute the root property list.
If my callback throws, the transaction is broken and we are done.
If it goes through, we issue the update... or delete.
It could look like this:
Alternatives
There may be a number of ways one could accomplish this.
Additional context
The text was updated successfully, but these errors were encountered: