-
Notifications
You must be signed in to change notification settings - Fork 298
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
@Unique: more on conflict options #1023
Comments
As stated on #509, my own use case can't rely on |
Implementing the current issue is enough in most cases, maybe in all cases. But what you think if user can himself decide the priority? @Unique(onConflict=IGNORE, priority=4)
var name: String = ""
@Unique(onConflict=FAIL, priority=3)
var address: String = ""
@Unique(onConflict=REPLACE, priority=2)
var phone: String = ""
@Unique(onConflict=UPDATE, priority=1)
var lastSeen: Long = 1234567890 The |
The |
This sounds like the existing |
I would like to move the discussion about my new proposal here. |
@greenrobot-team But |
Hello, there is some news? still need that implementation of |
Has there been any update about |
@deliqs What's your use case? E.g. why can't |
@greenrobot-team I'm building an offline first mobile app. I link the local/offline data to the central/online data by saving the central PK locally as a separate identifier once the data has been uploaded. I want to keep the local data in sync with the central data. So I currently check if any data is missing or outdated locally and get the missing/updated data from my central database. Please correct me if I'm wrong, but as far as I can see |
@deliqs Thanks for the details! Yes, if a replace occurs with |
I'm also looking forward to use this kind of UPDATE strategy. Is there any target date for releasing that feature? |
@Schmalztopf No, we will share once a feature is being worked on and when it's done. To help us track interest, thumbs up the first post. |
@Unique
currently supportsFAIL
andREPLACE
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 #509 (comment)
The text was updated successfully, but these errors were encountered: