odata-query icon indicating copy to clipboard operation
odata-query copied to clipboard

Filter with Any clause bad conversion

Open marcoziliotto opened this issue 4 years ago • 1 comments

Hi, thank you for your amazing query builder.

I ran into this problem: if I pass a filter object with this structure: { "Module1/Module_CategoryModule": { "any": { "Module_CategoryId": { "eq": 2 } } } }

I get this query, which throws a Syntax error in Restier OData: $filter=((Module1/Module_CategoryModule/any(module1/module_categorymodule:module1/module_categorymodule/Module_CategoryId%20eq%202)))

but actually the correct conversion would be this: $filter=((Module1/Module_CategoryModule/any(c:c/Module_CategoryId%20eq%202)))

Did I do something wrong in the filter syntax?

Thank you Marco

marcoziliotto avatar Mar 04 '22 12:03 marcoziliotto

Faced the same problem recently. The solution is not to use nested property accessors like 'Module1/Module_CategoryModule', but instead nest property access in objects like this:

{ Module1: { Module_CategoryModule: { any: { Module_CategoryId: { eq: 2 } } } } }

This approach generates a filter like so: $filter=((Module1/Module_CategoryModule/any(module_categorymodule:module_categorymodule/Module_CategoryId eq 2)))

LukasKusta avatar Aug 05 '24 05:08 LukasKusta