-
-
Notifications
You must be signed in to change notification settings - Fork 932
Description
API Platform version(s) affected: 4.2.*
Description
I'm playing with the new filter system in ApiPlatform 4.2, especially the OrFilter. It looks amazing!
However, I'm running into an issue with the Doctrine query when I also use the extension. I want to search in name, email, and phone properties. Here is my filter declaration:
new GetCollection(
parameters: [
'search' => new QueryParameter(
filter: new FreeTextQueryFilter(
new OrFilter(new PartialSearchFilter()),
properties: ['name', 'email', 'phone']
),
),
]
),
I also use the extension, which filters all queries by the organization. When I try to search records (search: Test), the query looks like
WHERE c0_.organization_id = ? OR LOWER(c0_.name) LIKE ? OR LOWER(c0_.email) LIKE ? OR LOWER(c0_.phone) LIKE ?
That gives incorrect results. Basically, the result is the same, as I wouldn't use the search filter at all. Is there a way to get a query like
WHERE c0_.organization_id = ? AND (LOWER(c0_.name) LIKE ? OR LOWER(c0_.email) LIKE ? OR LOWER(c0_.phone) LIKE ?)
so that the OrFilter can work with other filters/extensions?
How to reproduce
Create an extension that filters all queries by some field and define query parameter as stated above. Then call the endpoint with search query string.
Possible Solution
Additional Context
Originally asked in discussion #7429