objectbox / objectbox/objectbox-java

@Unique: more on conflict options

Offen
#1,023 13 Kommentare 25 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement
Vorherrschende Sprache
Java
Sterne
4.6k
Forks
311
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

@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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Verwende dieses Issue als Ausgangspunkt und prüfe zunächst, wie @Unique derzeit FAIL und REPLACE behandelt. Als abgeschlossen gilt die Unterstützung der vorgeschlagenen Verhaltensweisen IGNORE und UPDATE, einschließlich ihrer Reihenfolge, der relationserhaltenden Update-Semantik und der Einschränkung für mehrere UPDATE-Strategien; der Payload nennt keine Dateien oder Tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
databases
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.