objectbox-dart icon indicating copy to clipboard operation
objectbox-dart copied to clipboard

@Unique: more on conflict options

Open tanukijs opened this issue 3 years ago • 2 comments

Hello 👋

I ran into a problem with relationships that have a @Unique property. To be concise, an UPDATE strategy would be the solution. My problem has already been discussed in many PRs but not for objectbox-dart.

https://github.com/objectbox/objectbox-dart/issues/297 This PR concerned the REPLACE strategy. It works but my issue regarding this strategy is explained here: https://github.com/objectbox/objectbox-java/issues/1023#issuecomment-1014376019

@greenrobot-team But REPLACE doesn't automatically update the relations? If I have to check whether it got replaced during insert, then fix the relations manually it would be even more messy, I think.

After replacing duplications i end up with null relations which literally break my application.

https://github.com/objectbox/objectbox-java/issues/1023 So the UPDATE strategy would be a great solution.

tanukijs avatar Feb 04 '22 14:02 tanukijs

this enhancement will be very useful;

moSalamaa avatar Mar 07 '22 20:03 moSalamaa

Suggestion Instead of adding more onConflict strategies, we can have the conflictedId one way or another in UniqueViolationException so we have the freedom how to handle that. Note this id appears in the message

moSalamaa avatar Mar 10 '22 06:03 moSalamaa

similar to this https://github.com/objectbox/objectbox-java/issues/509#issue-344473626

AdelKanso avatar Sep 06 '22 08:09 AdelKanso