Reputation: 8753
odata query - is there a way to add an "and false" to a filter
This is a query connected to a SAP system.
Lets say my url is:
/PlannerGrpSet?$top=50&$filter=(Werks eq '3000')&$select=*
And I want to do:
/PlannerGrpSet?$top=50&$filter=(Werks eq '3000' and false )&$select=*
Don't ask me why, we have a tool that is translating some complex sql that we generate and in sql we do 0=1 to signify to not return data. Yes, I know we are insane.
Just adding and false gives:
The remote server returned an error: (500) Internal Server Error
Any ideas on how I get what I want? Again, not looking for "don't do that". Also I'd rather not rely on trying to do something like Werks eq '3000' and Werks eq '3001', ideally I wouldn't want to have to pick one of our columns at random and do something like that.
Upvotes: 1
Views: 2456
Reputation: 2915
The grammar for $filter
expressions does allow for a primitive literal (e.g., false
) on the right-hand side of an and
expression. So it looks like you are bumping up against a bug or limitation of the OData implementation behind your service.
Here's a working example from the TripPin demo service with a literal false
value in the $filter
.
http://services.odata.org/V4/(S(ztoosdlp5wrqdiv233gmrqys))/TripPinServiceRW/People?$filter=UserName eq 'russellwhyte' and false
You could try a different logical expression that is guaranteed to fail. E.g., 0 eq 1
.
Upvotes: 1