objectbox / objectbox/objectbox-java
QueryBuilder's notEqual doesn't return objects where that field is null
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 4.6k
- Fork
- 311
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
It's in the title, but a concrete example would be. Say we have a model with a String field called field. We have two objects in the database, one of them has field set to an empty String and another one has it set to null. The following query returns the one with the empty field but not the one with null:
box.query().notEqual(Model_.field, "hello world").build().find()
Basic info (please complete the following information):
- ObjectBox version: latest (2.7.1)
- Reproducibility: always
- Device: any
- OS: any
Expected behavior
An object with a particular field being null should match a notEqual which contains any non-null value, instead it doesn't.
Code
store = MyObjectBox.builder().androidContext(this).buildDefault()
val box = store.boxFor(Model::class.java)
box.removeAll()
Log.d("TEST_LOG", "putting null with id: " + box.put(Model(0, null)))
Log.d("TEST_LOG", "putting empty with id: " + box.put(Model(0, "")))
val logString = models.map { it.id }.sorted().joinToString()
Log.d("TEST_LOG", "models: $logString")
Where Model has a single String field called field
The above code clearly logs only the model with the empty field being returned but not the one with the null value for field. Maybe I'm misunderstanding something but this is a very unintuitive definition of notEqual and nothing in the docs seems to indicate it would behave this way.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da QueryBuilder.notEqual e segui il percorso della query utilizzato da box.query().notEqual(Model_.field, "hello world").build().find(), concentrandoti su come vengono gestiti i valori null dei campi. Aggiungi un caso di regressione basato sugli esempi di Model e verifica che la query restituisca sia l’oggetto con la stringa vuota sia l’oggetto null.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java, kotlin
- Ambito
- database
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100