feature: query filter support for common SQL keywords #2366
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
This extends our pagination query filter parsing to include various common SQL keywords:
And an additional "fake" keyword:
To accomplish this, two major changes were made:
With these changes, you can make some powerful queries. Here are a few example Recipe queries:
recipeCategory.name IN ["American", "German"]
tags.name CONTAINS ALL ["soup", "chicken", "easy"]
tags.name NOT IN ["small", "medium"]
You can also completely replace the custom filters we made for frontend filtering (more on that below):
recipeCategory.id CONTAINS ALL ["category-id-1", "category-id-2"] AND tags.id IN ["tag-id-1", "tag-id-2", "tag-id-3"] AND tools.id IN ["tool-id-1"]
Which issue(s) this PR fixes:
(REQUIRED)
N/A
Special notes for your reviewer:
(fill-in or delete this section)
I always hated the workaround I did in #1508 and #1560 to get filters working for categories/tags/tools, but the existing parser couldn't handle joins (e.g. recipe.tag.id) and assumed all values were singular (rather than lists).
There were a few other parser challenges, but those were the two main ones. I fixed the joins in #2265 and fixed the remaining issues here.
Testing
(fill-in or delete this section)
I added a bunch of tests prior to the refactor, then more after the refactor. God bless tests.
Once this PR is accepted, there are two tasks that should be done sooner or later:
Release Notes
(REQUIRED)