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

UniqueViolationException: insert the id of the duplicate document in an attribute #1039

Open
andrew-ld opened this issue Dec 22, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@andrew-ld
Copy link

UniqueViolationException currently in the instances created by objectbox itself in the error message is the id that conflicts with the document we want to insert, I wonder if it is possible to add this id as an attribute of the UniqueViolationException class, it would be useful.

@andrew-ld andrew-ld added the enhancement New feature or request label Dec 22, 2021
@greenrobot-team
Copy link
Member

greenrobot-team commented Jan 10, 2022

Thanks for the suggestion! I guess the expectation in this case is that the code never does a conflicting insert, e.g. it does a query beforehand to find a possible duplicate. Which can be used to obtain the object ID of a potential duplicate.

Or if the old object should be replaced, use the replace conflict strategy. https://docs.objectbox.io/entity-annotations#unique-constraints

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

No branches or pull requests

2 participants