-
Notifications
You must be signed in to change notification settings - Fork 574
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
Creating objects while in a manual transaction, should either create an object or throw #2638
Comments
My opinion is that manual transactions require a |
As minimum, we should clarify the documentation on the callers responsibility to cancel the transaction if any errors are thrown while interacting with it. I still think this is a bug though. It should either throw or create the object with the properties. I believe its an (highly unexpected) artifact of the implementation that the database can be left in a state where the object is created, but without values for its properties. |
I talked with @jedelbo about this and it turns out Core 6 has a method to create an object, with values which might be a great way to implement a fix for this issue (https://github.com/realm/realm-core/blob/next-major/src/realm/table.hpp#L274-L279). |
Goals
Calls to
realm.create()
should either create an object or throw (while in a manual transaction).Expected Results
If
realm.create
throws, I expect no side-effects on the database (ie. no rows with default values created).Actual Results
Calling
realm.create
with missing values, while in a manual transaction throws but also creates an object with default values.Steps to Reproduce & Code Sample
☝️ throws
Listing the objects afterwards reveals an object was actually created:
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: