Closed mahmoud-araby closed 8 months ago
after trying to test many cases I think the issue is in using or it, not the isNull()
QueryBuilder<OrderModelDto> queryBuild= _dbController.box<OrderModelDto>().query(OrderModelDto_.businessDate
.equals(orderFilter.businessDate!.millisecondsSinceEpoch)
.or(OrderModelDto_.sessionUid.isNull()));
queryBuild.link(OrderModelDto_.orderType, OrderTypeDto_.id.equals(5));
QueryBuilder<OrderModelDto> queryBuild= _dbController.box<OrderModelDto>().query(OrderModelDto_.businessDate
.equals(orderFilter.businessDate!.millisecondsSinceEpoch)
.or(OrderModelDto_.sessionUid.equal("notFound")));
queryBuild.link(OrderModelDto_.orderType, OrderTypeDto_.id.equals(5));
both code samples above returned the same result
I also tried to use a single condition with link and isNull and the result was correct
QueryBuilder<OrderModelDto> queryBuild= _dbController.box<OrderModelDto().query(OrderModelDto_.sessionUid.isNull());
queryBuild.link(OrderModelDto_.orderType, OrderTypeDto_.id.equals(5));
Thanks for reporting. However, without knowing what data you are working with it's hard to guess what you expect to be the correct result.
Maybe note that "link" conditions are always added with "and".
If that does not clear things up, please share a small example project to help me understand your issue better.
Thanks for replaying. I have created a small example project with the case
https://github.com/mahmoud-araby/object_boc_relation_test
Steps To Reproduce : 1- Download the Source Code and run it on any platform (Windows, Android, IOS). 2- Project Have a Single Page With One Query (Total . OR Discount ) Link User. Name. 3- Try to put values in the TextFields and Reult Will Pop on the Screen. 4- You can find the initial data in /assets/data.json.
Try to Put Total And Discount more significant than the data in Tables with Specific User Name but Query still returns all data with Link to the User Name.
Thanks! I can confirm that when adding the link condition it appears the actual conditions are ignored completely.
Log output:
[Query Describe Parameters] (total >= 20.000000
OR discount >= 3.000000)
| Link User via userId with conditions: name contains "1"
[Query Describe] Query for entity UserOrder with 3 conditions with properties total, discount, total with 1 links
We'll look into this.
We have released version 2.3.0
which resolves this issue. Please update using flutter pub upgrade
(or dart pub upgrade
for Dart Native projects).
Thanks again!
If add a link, backLink in QueryBuilder and add or() in entity condition ( not the linked entity ) returned result using find, findAsync is not accurate following the returned data if think that return is like executing the main condition and the link in two separate functions.
Basic info:
Steps to reproduce
Expected behavior
the returned result must be a and between a link and a specific condition as explained in the doc :
but the query returns all results from the link and condition as if they are executed separately.
Code
The return data count is greater than the condition itself without a link as if the link is not looking anymore at the condition on OrderModelDto