question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create OData filter for `null` (`eq` and `ne`)

See original GitHub issue

Hi, 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 strings 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:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jjtang1985commented, Jun 10, 2021

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

1reaction
lennart-mcommented, Jun 10, 2021

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 with lastName=null although this would be semantically correct).

Sincerely,

Lennart

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Odata Filter Null - Power Platform Community - Microsoft
Solved: Does anyone know how to use an odata filter on a SharePoint Get Items action to filter out items with a null...
Read more >
OData filter options (handle null or empty values)
My question is regarding handling of null values in OData $filter. If the user does not enter any value for CustomerID then we...
Read more >
odata filter for null values - SAP Community
Hi Folks, we have created odata services for calculation script views. now in the json format links we want to filter values for...
Read more >
How To Check Null Value In ODATA Filter Of Get Items Action ...
In this blog, we will see which options won't work and what is the correct way to write filter parameter to check not...
Read more >
Power Automate OData filter query with examples - SPGuides
In this query, we are specifying to filter the data where EmployeeName is not equal to Null. We are using “ne” i.e Not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found