-
-
Notifications
You must be signed in to change notification settings - Fork 344
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 filter query when using "OR" conditions #1358
Conversation
0b06615
to
38fbdcc
Compare
20ae7f0
to
1454d4f
Compare
We could evaluate if in the next major, we could provide the |
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.
If I understand correctly.
If you've add a where(Foo)
is the configure query.
And you're using a filter1 with AND, a filter3 with OR, a filter2 with AND and a filter4 with OR.
You will get where Foo AND filter1,
then where Foo AND filter1 AND (filter3)
then where Foo AND filter1 AND (filter3) AND filter2
then where Foo AND filter1 AND (filter3 OR filter4) AND filter2
So what you're calling a root filter condition, could more related to the Or. getOrFilterCondition
? Same for the marker.
Would it be possible to add test unit ?
Let's say you have the following datagrid query: SELECT ...
FROM model m
WHERE
m.enabled = true
AND m.updated_at IS NULL
; The changes introduced in this PR will perform these actions:
SELECT ...
FROM model m
WHERE
m.enabled = true
AND m.updated_at IS NULL
AND (
"sonata_admin.datagrid.filter_query.marker" IS NULL
)
;
SELECT ...
FROM model m
WHERE
m.enabled = true
AND m.updated_at IS NULL
AND (
"sonata_admin.datagrid.filter_query.marker" IS NULL
OR m.name LIKE "%my search criteria%"
OR m.lastname LIKE "%my search criteria%"
)
;
Yes, that's in my To Do list, but I'd like to confirm if the results are the expected in other real project before spending time on them. In my case, it is working fine, but please let me know if you have chance to check it on your side. |
Yes, so the method
I don't consider this as the root condition, but only the one related to OrFilter. |
Since |
I will try to use this in the week, but since we've overridden the default search behavior I need some work/time. |
bef6f82
to
b1972ec
Compare
cc1df5c
to
7cc1086
Compare
b27e3e9
to
f680e97
Compare
656d079
to
0025e97
Compare
@sonata-project/contributors, could you please review? |
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.
I still didn't find time to try this.
Does someone did ?
*/ | ||
private function addOrParameter(BaseProxyQueryInterface $query, $parameter): void | ||
{ | ||
$adminCode = $this->getOption('admin_code'); |
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.
Even if we usually will use the admin code which a filter belongs to as value for this option, I think we could use a more agnostic name, since this option has no actual relation with an admin code; it's just a grouping identifier used to know which filters must share the same condition.
WDYT about "group" or something similar?
Subject
Fix filter query when using "OR" conditions.
I am targeting this branch, because these changes respect BC.
Rework of #925, keeping BC.
Fixes sonata-project/SonataAdminBundle#2850.
Fixes sonata-project/SonataAdminBundle#3368.
Fixes sonata-project/SonataAdminBundle#5569.
Changelog
To do
AND WHERE
clause for first time without using a static variable;