-
Notifications
You must be signed in to change notification settings - Fork 307
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
Creating queries with complex 'and' and 'or' combinations #201
Comments
Yes, the query API subject to changes and this will be solved, of course. :-) |
Hey! We recently started using this library and so far looks great, but this is a really good feature needed. Any update on this issue? |
Copying from #533: A new query API is in testing internally, but currently on hold. |
We really need this feature. Do we still nedd to wait for long? |
We are currently spending most of our time on building sync. I can't say when the new query API will be released. |
An example for List<User> query = box.query(
User_.propA.equal(x).and(User_.propB.equal(y))
.or(User_.propC.equal(s).and(User_.propD.equal(t)))
).build().find(); |
Hi, I don't know if this is doable in Java or not, but I think it would be easier if we could type something like this: List query = box.query(user -> It's very similar to what c# has into LinQ, but like I say, I don't know if it's doable in Java or in ObjectBox or how much effort would it take. |
@Zpecter Thanks for this suggestion. If you are using the Kotlin infix functions for val query = box.query(
user.propA.equal(x) and user.propB.equal(y) or user.propC.equal(s) and user.propD.equal(t)
).build().find() Edit: I'm not aware how to create infix functions like this or to e.g. overload operators in Java. Open to pointers. |
E.g. using above example: val query = box.query(
user.propA equal x and (user.propB equal y) or (user.propC equal s) and (user.propD equal t)
).build().find() |
What about this condition? WHERE It's a little bit confusing the use of "and" and "or" and mixing them. Any suggestion? |
Question: Am I missing something or has querying on links not been ported over to the new API yet? |
@Queatz It should work. Have an example where it doesn't? |
@greenrobot I think I commented on the wrong issue...my question was specific to the new query builder and support for querying on links. I couldn't find anything on the |
@Queatz This should work: Hint: as noted in the Javadoc |
Note: This is also available with |
This is now available with the |
Closing. If there is an issue with the new query API, feel free to raise a new issue. |
According to QueryBuilder documentation, we can define the order of logical operations using implicit and(). However, this implementation does not allow us to create complex conditions, such as
(A and B) or (C and D)
. This comment provides a workaround, but having Realm-like chainable queries would be much nicer. Is changing existing QueryBuilder mechanics planned in future versions?The text was updated successfully, but these errors were encountered: