objectbox / objectbox/objectbox-java
Store Map values as Long instead of Int
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.6k
- Forks
- 311
- PR merge metrics
- No merged PRs in 30d
Description
Is there an existing issue?
- I have searched existing issues
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by tracing how MutableMap<String, Any> values are serialized and why the attempted PropertyConverter does not work for this mapping; then define how the proposed annotation should preserve Long values and verify the stored and retrieved values remain Long.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- database, mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100