jaydata icon indicating copy to clipboard operation
jaydata copied to clipboard

Filtering on navigation properties for a set of value with toLowerCase

Open perepechin opened this issue 11 years ago • 0 comments

I have this JayData query (it can be checked at JSLQ playground):

northwind.Products .filter( function( product ) { return product.ProductName.toLowerCase() in ['tofu']; } ) .toArray( function( products ) { console.dir( products ); } ); This query produces incorrect filter expression: http://services.odata.org/Northwind/Northwind.svc/Products?$filter=(tolowerProductName%20eq%20%27tofu%27)&$callback=parent.handleJSONP_21&$format=json

So you can see that we have tolowerProductName, but it should be tolower(ProductName), so the right filter query should looks like this: http://services.odata.org/Northwind/Northwind.svc/Products?$filter=%28tolower%28ProductName%29%20eq%20%27tofu%27%29&$callback=parent.handleJSONP_21&$format=json

Later I found that incorrect filter expression produces this line of code (for query with 'in' operator):

context.data = temp + context.data.replace(/(/g, '').replace(/)/g, ''); Line 1542 in oDataProvider.js - https://github.com/jaydata/jaydata/blob/development/release/jaydataproviders/oDataProvider.js#L1542

I replaced it with this code: context.data = temp + context.data;

And now everything is working as expected. Maybe I introduced other issues with this fix, but at least it works as expected for my queries.

I asked and answered myself on this issue here - http://stackoverflow.com/questions/22749086/filtering-on-navigation-properties-for-a-set-of-value-with-tolowercase/

perepechin avatar Mar 30 '14 21:03 perepechin