objectbox / objectbox/objectbox-java
@Unique: more on conflict options
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.6k
- Forks
- 311
- PR merge metrics
- No merged PRs in 30d
Description
@Unique currently supports FAIL and REPLACE that are compatible with Sync.
Proposal to add more options (that likely will not work with Sync):
@Unique(onConflict=IGNORE): ignore the offending object (no changes to the existing conflicting object). If there are multiple unique properties in an entity, this strategy is evaluated first:
if the property conflicts, no other properties will be checked for conflicts.
@Unique(onConflict=UPDATE): the offending object overwrites the existing conflicting object while keeping its ID. Thus, all relations pointing to the existing entity stay intact.
This is useful for a "secondary" ID, e.g. a string "ID". Within an entity, this strategy may be used once only (update target would be ambiguous otherwise).
Multiple strategies in an entity are processed in this order: IGNORE, FAIL, REPLACE, UPDATE.
Originally posted by @greenrobot in https://github.com/objectbox/objectbox-java/issues/509#issuecomment-425055199
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use this issue as the starting point and first review how @Unique currently handles FAIL and REPLACE. Define done as supporting the proposed IGNORE and UPDATE behaviors, including their ordering, relation-preserving update semantics, and the restriction on multiple UPDATE strategies; the payload names no files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100