objectbox / objectbox/objectbox-java

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

オープン
#915 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement
主要言語
Java
スター
4.6k
フォーク
311
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

QueryBuilder.notEqual から開始し、box.query().notEqual(Model_.field, "hello world").build().find() で使用されるクエリパスを追跡して、フィールド値が null の場合にどのように処理されるかに注目します。Model の例に基づく回帰ケースを追加し、クエリが空文字列のオブジェクトと null のオブジェクトの両方を返すことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, kotlin
領域
database
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。