Skip to content

[Search] Search query is missing entities in specific edge case #7290

@KDederichs

Description

@KDederichs

Describe the bug
I've run into a specific search edge case where it won't search on nested entities when you search on an entity in 2 different parent entities.

To Reproduce

Have an Entity Foo with something you want to search on, lets call it fooBarBaz.

Then define 2 new entities Bar and Baz that both reference Foo $foo using ManyToOne relations.

Lastly have an entity that contains a ManyToOne reference to both Bar $bar and Baz $baz let's call that BarBaz

Then you configure the search in your your BarBazCrudController like this:

    public function configureCrud(Crud $crud): Crud
    {
        return $crud
            ->setSearchFields(
                [
                    'bar.foo.fooBarBaz',
                    'baz.foo.fooBarBaz'
                ]
             );
    }

In this case you'll only ever get the Bar entities that contain a matching Foo entity, the Baz ones will be omitted.

Looking at the query in the profiler I think it's related to how those are joined.
Which ever entity first joins the Foo entity will get searched, the rest will be skipped.

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