-
Notifications
You must be signed in to change notification settings - Fork 305
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Milestone
Description
Describe the bug
Despite explicit setting different parameter value subsequent query executions return same result sometimes (if made quickly enough, or maybe two different parameter values have same hash?)
Basic info (please complete the following information):
- ObjectBox version: 3.1.2
- Reproducibility: occasionally without visible pattern
- Device: emulator, Sony Xperia XII
- OS: Android 10
To Reproduce
See code section
Expected behavior
For different parameters values results must be different.
Code
@Entity
class KAEntry(
@Unique val key: String,
val value: String,
@Id var id: Long = 0
)
...
val boxStore: BoxStore = MyObjectBox.builder().androidContext(context).build()
val kAEntryBox = boxStore.boxFor(KAEntry::class.java)
val byKeyQuery = kAEntryBox.query().equal(KAEntry_.key, "", CASE_SENSITIVE).parameterAlias("key").build()
kAEntryBox.put(KAEntry("currentUser.lastUnlockTimestamp","123123"))
kAEntryBox.put(KAEntry("currentUser.navigationStack","some other value"))
val result1: KAEntry? = byKeyQuery.setParameter("key", "currentUser.lastUnlockTimestamp").findUnique()
val result2: KAEntry? = byKeyQuery.setParameter("key", "currentUser.navigationStack").findUnique()
if (result1?.key == result2?.key) {
// this shouldn't be possible since I'm querying by different keys.
error("Query returned same result twice")
} else {
// fine this time
}Additional context
I assumed that this is issue with reuse of byKeyQuery object and instead of reusing it I create new query every time. I'm not 100% sure yet if this helped since this issue is very sporadic, but I'll know if it reappears.
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request