-
Notifications
You must be signed in to change notification settings - Fork 46
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
How to Filter On Null #425
Comments
Hi @SpaceCondor, in the OData client of the Cloud SDK it's possible to create such a filter the following way: ValueBoolean filterFunction = FieldReference.of(BusinessPartner.FIRST_NAME.getFieldName()).equalTo(Expressions.Operand.NULL) If you are using our OData V2 VDM you can then also consumer that filter the following way: new DefaultBusinessPartnerService()
.getAllBusinessPartner()
.filter(new UncheckedFilterExpression<>(filterFunction)); This is, however, only a workaround and will be improved on in the future. For our OData V4 VDM there is no such workaround possible at the moment. If that already answers your question, feel free to close the issue, or let me know what I missed. Greetings |
Thank you! Unfortunately we are using V4 so that workaround won't work. Glad to know it is on your radar! |
Is "COMMENTS" a |
@SpaceCondor , my suggestion would look like the following - have you tried...? FilterableBoolean<Order> noCommentsFilter = Order.COMMENTS.length().equalTo(0); Alternatively, if you want to enforce the FieldUntyped fieldUntyped = FieldReference.of(Order.COMMENTS.getFieldName());
ValueBoolean.Expression fieldExpression = (ValueBoolean.Expression) fieldUntyped.equalTo((Object) null);
FilterableBoolean<Order> noCommentsFilter = new FilterableBoolean.Expression<>(fieldExpression, Order.class); Or another potential solution is to use our OData Generic Client for OData experts, but it may not take advantage of your generated OData API. Please understand we're still investigating the |
Hey @newtork, thanks for the suggestion! I actually had already tried that, but wasn't successful. In this example, COMMENTS is a string, not a collection. I will play around with the generic client to see if I can get something workable in the meantime. |
@SpaceCondor wrote:
I'm sorry, I misinterpreted your question then. Please use the following simple expression: FilterableBoolean<Order> noCommentsFilter = Order.COMMENTS.equalTo((String) null); Your IDE may complain the function argument is annotated as non-null. We fixed the annotation to nullable for next relaese. But it should work for you already. |
As of
|
Discussed in #424
Originally posted by SpaceCondor August 17, 2021
Is it possible to filter on a value being 'null'? I am trying to filter on a particular String being
null
.For example:
.filter(Order.COMMENTS.equalTo(null))
The text was updated successfully, but these errors were encountered: