Create OData filter for `null` (`eq` and `ne`)
See original GitHub issueHi, I have a question about filtering entity sets using the cloud SDK. I would like to read an entity set, filtering on all entities that have value null
in a specific field.
So the resulting URL should be:
GET https://myserver/odata/v2/User?$filter=lastName eq null
The question also applies to ne
instead of eq
.
Unfortunately I am not able to create such filter using the cloud SDK. I tried something like User.LAST_NAME.equals(null)
but this gives a TS error as only string
s are allowed.
Also, explicit type casting does not work: User.LAST_NAME.equals(null as unknown as string)
will create a filter lastName eq 'null'
.
I might be able to manually set the URL query string for this filter but I would like to use this filter along with other filters, created by the cloud SDK. So does not seem to be an alternative.
Is it possible to achieve this using the cloud SDK?
Thanks a lot, Lennart
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Hi @lennart-m ,
I can reproduce the type error and I created a backlog item.
Please share your timeline, if possible.
Thank you very much.
Best regards, Junjie
Hi @jjtang1985 and @artemkovalyov, thank you very much for handling this. The application I’m working on will probably go live within a few months. I am now implementing a workaround by not writing null values to the required fields in the remote system so I can filter properly. So there is no urgency.
By the way, the remote system is SAP SuccessFactors so this issue will perhaps come up more often; a workaround for this is not that easy due to the behavior of SuccessFactors when filtering (a filter on
lastName ne 'name'
will not find entities withlastName=null
although this would be semantically correct).Sincerely,
Lennart