objectbox / objectbox/objectbox-java
QueryBuilder's notEqual doesn't return objects where that field is null
还没有人认领这个 Issue。
- 主要语言
- 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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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