-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Support optimistic locking in mongodb #3612
Comments
Versions are managed automatically, you can't set the value yourself, it is ignored when computing changesets, and moreover, this is SQL only feature, it's not implemented in mongo driver at all. |
Ah, I see. I saw that the reference documentation actually says this is SQL only. Maybe an entry could be added to the "Transactions and Concurrency" tab as well? The Starting v3.4, transactions are also supported in MongoDB driver. is kind of misleading 😛 |
which part is misleading? transactions are supported in mongo, this is purely about locking. pessimistic locking is SQL feature (it literally maps to SQL keywords), but for optimistic locks I am sure we can find a way to support it in mongo rather easily |
There are places in the documentation that clearly specify that functionality X is not available on nosql drivers and such. Transactions and Concurrency page does not specify under "Optimistic Locking" that is does not support mongo. I was reading the version explanation and didn't notice it was not available for MongoDB and kept trying different things thinking I was doing something wrong (which I was, using that when I should not be using since I'm using MongoDB haha) Maybe just a *currently only supported in SQL drivers below the Optimistic Locking text would be enough! What do you think? |
Describe the bug
Inserting version: true inside the @Property decorator makes the field not get persisted in the database when running the MongoDB driver.
To Reproduce
Steps to reproduce the behavior:
Call either new User(data) or through em.getRepository(User).create({...data, version: 1})
You'll see that the version field does not get persisted
Expected behavior
Version field should go to the database in order for optimistic concurrency error handling to happen
Versions
Running ^5.4.2" of both @mikro-orm/core and @mikro-orm/mongodb
The text was updated successfully, but these errors were encountered: