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

Multi filters with multiple comparators #842

Open
AnnekimBanchereau opened this issue Dec 20, 2023 · 3 comments
Open

Multi filters with multiple comparators #842

AnnekimBanchereau opened this issue Dec 20, 2023 · 3 comments
Labels
bug Something isn't working will accept PR

Comments

@AnnekimBanchereau
Copy link

Hello,
thank you for your very useful library.
Unfortunately, we have some issues with multi filters.

orders?filter.families=$ilike:REMOV&filter.families=$or:$ilike:IMPLANT&filter.dentistName=$ilike:b

The generated request is :

WHERE (UPPER(`product`.`families`) LIKE UPPER(?) OR UPPER(`product`.`families`) LIKE UPPER(?) AND UPPER(`product`.`dentistName`) LIKE UPPER(?))

In this case, the last filter dentistName is not working, because it is located between the brackets.

The documentation explains :

Note: The first comparator on the first filter is ignored because the filters are grouped by the column name and chained with an $and to other filters.

...&filter.id=5&filter.id=$or:7&filter.name=Milo&...

is resolved to:

WHERE ... AND (id = 5 OR id = 7) AND name = 'Milo' AND ...

The expected generated request should be:

WHERE (UPPER(`product`.`families`) LIKE UPPER(?) OR UPPER(`product`.`families`) LIKE UPPER(?)) AND UPPER(`product`.`dentistName`) LIKE UPPER(?)

Thank you for your help :)

@ppetzold
Copy link
Owner

seems like a bug. multi filters coverage is minimal. your expected where expression is definitely the intended version.

@ppetzold ppetzold added bug Something isn't working will accept PR labels Dec 21, 2023
@natoszme
Copy link

natoszme commented May 8, 2024

Hy there! Any updates on this? Thanks

@linsolas
Copy link

linsolas commented Jul 12, 2024

Hello all,

I just encountered the same issue as you. However, it seems it is resolved by adding the $or: even for the first filter value (despite what the document says), so something like this:

- orders?filter.families=$ilike:REMOV&filter.families=$or:$ilike:IMPLANT&filter.dentistName=$ilike:b
+ orders?filter.families=$eq:$ilike:REMOV&filter.families=$or:$ilike:IMPLANT&filter.dentistName=$ilike:b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working will accept PR
Projects
None yet
Development

No branches or pull requests

4 participants