Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

OrFilter with nullable nested relation

Abierto
#8,655 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
54/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
php

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
PHP
Estrellas
2.6k
Forks
987
Merge medio
1 d 10 h
PR fusionados (30 d)
76

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de api-platform/core

Todos los issues de api-platform/core

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.