Skip to content

Store Map values as Long instead of Int #1181

Open
@alghe-global

Description

@alghe-global

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions