objectbox / objectbox/objectbox-java

QueryBuilder's notEqual doesn't return objects where that field is null

Abierto
#915 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement
Lenguaje dominante
Java
Estrellas
4.6k
Forks
311
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en QueryBuilder.notEqual y sigue la ruta de consulta utilizada por box.query().notEqual(Model_.field, "hello world").build().find(), centrándote en cómo se gestionan los valores de campo null. Añade un caso de regresión basado en los ejemplos de Model y verifica que la consulta devuelva tanto el objeto con la cadena vacía como el objeto null.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java, kotlin
Área
database
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.