Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter with Any clause bad conversion #103

Open
marcoziliotto opened this issue Mar 4, 2022 · 1 comment
Open

Filter with Any clause bad conversion #103

marcoziliotto opened this issue Mar 4, 2022 · 1 comment

Comments

@marcoziliotto
Copy link

marcoziliotto commented Mar 4, 2022

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

@LukasKusta
Copy link

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)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants