Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OData query $filter conditions and case-sensitivity

Does OData specify whether filter conditions on string fields are to be evaluated case-sensitively or case-insensitively?

Example: (from the docs)

/Suppliers?$filter=Address/City eq 'Redmond'  

Is this expected to be case-sensitive or not?

If I want to offer both options, how can this be expressed? There is a tolower() function that can be used like:

/Suppliers?$filter=tolower(Address/City) eq 'redmond' 

or

/Suppliers?$filter=tolower(Address/City) eq tolower('Redmond') 

Isn't there a more concise way to express case-insensitive matching?

like image 769
eseib Avatar asked Nov 21 '12 14:11

eseib


People also ask

Is OData query case sensitive?

OData API filter value which you are selecting for $FILTER parameter is always case sensitive.

How does $filter work in OData?

The $filter system query option allows clients to filter the set of resources that are addressed by a request URL. $filter specifies conditions that MUST be met by a resource for it to be returned in the set of matching resources. The semantics of $filter are covered in the OData:Core document.

How do you handle special characters in OData query?

Do not use the “JavaScript String replace() Method”. It will replace the first occurrence of the special characters. If you have 2 occurance of the same special characters in the filtering parameter, it will fail. So use the regular expression to replace the characters.

What is $select in OData?

The $select option specifies a subset of properties to include in the response body. For example, to get only the name and price of each product, use the following query: Console Copy. GET http://localhost/odata/Products?$select=Price,Name.


1 Answers

The "eq" operator is supposed to be case sensitive. Usage of tolower (or toupper) is the currently recommended way of doing this.

like image 56
Vitek Karas MSFT Avatar answered Sep 21 '22 23:09

Vitek Karas MSFT