OrFilter with nullable nested relation
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 54/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- backend-api-design
Direzione di ricerca
Start by tracing how FreeTextQueryFilter, OrFilter and PartialSearchFilter build joins for nested properties, then inspect the relevant filter tests for nullable relations. Reproduce the example with a nullable relation and a matching scalar field. Done means the root resource is still returned when the scalar field matches, while nested-property matching continues to work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
API Platform version(s) affected: 4.4.3
Description
When using FreeTextQueryFilter together with OrFilter(new PartialSearchFilter()), nested relational properties are joined with INNER JOIN.
This becomes a problem when one of these relations is nullable.
Because of the INNER JOIN, root resources are excluded from the result set before the OR conditions are evaluated. As a result, an entity can fail to match even if one of its direct scalar fields does match the search term.
Example
I have a User resource with this parameter:
#[QueryParameter(
key: 'search',
filter: new FreeTextQueryFilter(new OrFilter(new PartialSearchFilter())),
properties: ['name', 'internalPhone', 'externalPhone', 'department.name', 'service.name', 'job.title']
)]
Some relations such as service, department, or job are nullable.
Example data:
-
User A:
- name = "John Doe"
- service = null
-
User B:
- name = "Other User"
- service.name = "IT"
Request
GET /users?search=john
Actual behavior
User A is not returned, even though name matches "john".
This appears to happen because nested properties like service.name are joined using INNER JOIN, so users with service = null are removed from the query result before the OR expression is applied.
Expected behavior
For nullable relations, nested properties used by text search should not exclude the root entity when the relation is null.
In this case, we would expect a LEFT JOIN so that:
name LIKE '%john%'
OR internalPhone LIKE ...
OR externalPhone LIKE ...
OR service.name LIKE ...
etc.
can still match on direct fields even if a nullable relation is absent.
How to reproduce
Possible Solution ``
Additional Context
- Lingua principale
- PHP
- Stelle
- 2.6k
- Fork
- 987
- Merge medio
- 1g 8h
- PR unite (30g)
- 80
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di api-platform/core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
api-platform/core#8665 ·
I maintainer di solito rispondono entro 1 giorno
-
Doctrine\Orm\OrderExtension fails on SortDirectionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
api-platform/core#8660 ·
I maintainer di solito rispondono entro 1 giorno
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
api-platform/core#8650 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
api-platform/core#8649 ·
I maintainer di solito rispondono entro 1 giorno
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
api-platform/core#8648 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di api-platform/core
Issue simili
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 4 giorni
-
Перевод устарел
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
bug
Difficoltà 2/5 Mezza giornata Idoneità per principianti 76/100
m3ue/m3u-editor#1604 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
femiwiki/docker-mediawiki#1497 ·
I maintainer di solito rispondono entro 1 giorno