objectbox / objectbox/objectbox-java
QueryBuilder's notEqual doesn't return objects where that field is null
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 4.6k
- Fork
- 311
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại QueryBuilder.notEqual và theo dõi đường dẫn truy vấn được box.query().notEqual(Model_.field, "hello world").build().find() sử dụng, tập trung vào cách các giá trị trường null được xử lý. Thêm một trường hợp hồi quy dựa trên các ví dụ về Model và xác minh rằng truy vấn trả về cả đối tượng có chuỗi rỗng và đối tượng null.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, kotlin
- Lĩnh vực
- database
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100