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

Fix sql query for multifilter #970

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Conversation

anddyyyy46
Copy link
Contributor

There was a bug regarding multifilter.

The filters were split depending on whether they had an or operator or an and operator somewhere. However, multifilter may start with an and operator and have or operators inside. This meant that they were used twice and it also caused problems that an and operator binds stronger than an or operator.

Example:

filter: {
    name: ['Milo', '$or:Garfield'],
    color: ['brown', '$or:white'],
}

SQL Query: ... WHERE ( ("__root"."name" = "Milo" OR "__root"."name" = "Garfield" AND "__root"."color" = "brown" OR "__root"."color" = "white") AND ("__root"."name" = "Milo" OR "__root"."name" = "Garfield" AND "__root"."color" = "brown" OR "__root"."color" = "white")

(See: ... OR "__root"."name" = "Garfield" AND "__root"."color" = "brown" OR ...)

Now in my changes the first operator of a filter is checked, so they are not used twice and also filters that starts with an and operators are put in extra brackets, since in the case of a multifilter they contain or operators and otherwise you would have problems again because of the stronger binding of an and operator.

Example:

filter: {
    name: ['Milo', '$or:Garfield'],
    color: ['brown', '$or:white'],
}

SQL Query: WHERE ( ("__root"."name" = "Milo" OR "__root"."name" = "Garfield") AND ("__root"."color" = "brown" OR "__root"."color" = "white") )

Copy link
Owner

@ppetzold ppetzold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff 🚀

LGTM

@ppetzold
Copy link
Owner

ppetzold commented Sep 9, 2024

@anddyyyy46 can you run npm run format and commit? ci is failing

@ppetzold ppetzold merged commit 1883c2d into ppetzold:master Sep 9, 2024
3 checks passed
@ppetzold
Copy link
Owner

ppetzold commented Sep 9, 2024

🎉 This PR is included in version 9.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants