objectbox / objectbox/objectbox-java

Store Map values as Long instead of Int

Offen
#1,181 8 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Is there an existing issue?
Use case

I am storing a mapping:

val mapping = mutableMapOf(
    "key1" to mutableMapOf(
        "subkey1" to 1L,
        "subkey2" to 1L,
        "subkey3" to 1L
    ),
   "key2" to 1L

that is represented in the data class as follows:

@Entity
data class MyDataClass(
    @Id var id: Long = 0,
    var mapping: MutableMap<String, Any>? = null

ObjectBox will store the Long values as Ints due to not being wide enough. These breaks use cases where we do want to store the Long values as Long and not as Ints (for example test cases that use the same generated mock data to store in the database and to test against).

Proposed solution

Have an annotation that tells ObjectBox to store Long values as Long.

Alternatives

Tried using a PropertyConverter however this breaks for the mapping I've provided.

Additional context

Kotlin
Android

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

Das Issue nennt keine Dateien oder Tests. Beginnen Sie damit nachzuverfolgen, wie MutableMap<String, Any>-Werte serialisiert werden und warum der versuchte PropertyConverter für dieses Mapping nicht funktioniert; legen Sie anschließend fest, wie die vorgeschlagene Annotation Long-Werte erhalten soll, und überprüfen Sie, dass die gespeicherten und abgerufenen Werte weiterhin Long sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, java, kotlin
Bereich
database, mobile
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.