-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
SearchKit - Allow functions in the WHERE clause #22241
Conversation
(Standard links)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks @colemanw! I've done a quick round of testing and discovered that the generated API4 request appears to be missing the isExpression
bool in where
clauses with functions. The generated request for Year Only Birth Date = 1991
looks like this:
{
"version": 4,
"select": [
"id",
"display_name"
],
"orderBy": [],
"where": [
[
"YEAR(birth_date)",
"=",
1991
]
],
"groupBy": [],
"join": [],
"having": []
}
It should look like this:
{
"version": 4,
"select": [
"id",
"display_name"
],
"orderBy": [],
"where": [
[
"YEAR(birth_date)",
"=",
1991,
true
]
],
"groupBy": [],
"join": [],
"having": []
}
@pfigel are you sure about that? My understanding is that the 4th boolean argument controls how the 3rd argument is interpreted, not the first. I think the first argument is always parsed as an expression, because a field name is expected. |
62c7b5c
to
5ded42f
Compare
Thanks @pfigel - you're right, but IMO that was too restrictive. The first arg of the WHERE clause is always interpreted as an expression, so functions ought to be allowed regardless of the 4th param. I've loosened the restriction and added a unit test to ensure it works correctly in both modes. |
Overview
Advanced feature for SearchKit allows SQL functions in the WHERE clause. They are selected in the same way as the "Field Transformations" tab.