Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

OrFilter with nullable nested relation

Aperta
#8,655 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di api-platform/core

Tutte le issue di api-platform/core

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.