New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async property query returns result too early #70
Comments
In the meantime, the users should final all = box.getAll(); // or some query
final sum = all.map((s) => s.someIntProp ?? 0).toList().reduce((a,b) => a + b); // ?? if prop is nullable
final avg = sum / box.count();
final maxEntityOfSomeProp = all.reduce((a, b) => a.someIntProp > b.someIntProp ? a : b);
final maxOfProp = maxEntityOfSomeProp[0].someIntProp; |
There is no async property query. The native call is synchronous, it cannot return before the data is ready. I've found the issue causing wrong results of Closing this issue, let's address the rest (if there are any more problems) in a property-query PR. BTW regarding all the OBX_*_array structs - could a generic be used instead of having a copy of each? That should also reduce the amount of duplication in the caller code |
If you run the branch #51 and #58, and compare the
count
andfind
result on thePropertyQuery
, you'll find that thefind
function sometimes returns a partially correct result set, with certain random bytes (every time you run it), that are the same as the random bytes ascount
consistently returns.This leads me to think that these obx functions return via ffi before the actual correct values are populated on the array alloc. This reminds me of the async
await
theFuture
discussion #49 .The text was updated successfully, but these errors were encountered: