Skip to content

OrFilter with nullable nested relation #8655

Closed

Description

@AirBair

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

Activity

  1. added a commit that references this issue on Oct 12, 2026
    3e04ee3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions