objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
970 stars 119 forks source link

@Unique: more on conflict options #378

Open tanukijs opened 2 years ago

tanukijs commented 2 years ago

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.

moSalamaa commented 2 years ago

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

AdelKanso commented 1 year ago

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