Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

OrFilter with nullable nested relation

Đang mở
#8,655 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
54/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend-api-design

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
PHP
Star
2.6k
Fork
987
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
76

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/core

Tất cả issue của api-platform/core

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.