Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple JOINS to same table and filters fails at ORM/ExpressionBuilder #314

Open
enpepet opened this issue Nov 7, 2023 · 0 comments
Open

Comments

@enpepet
Copy link

enpepet commented Nov 7, 2023

The problem is that when using a Filter it adds the condition to the first join if there are multiple joins with same table.

at src/Bundle/Doctrine/ORM/ExpressionBuilder.php resolveFieldByAddingJoins calls getFieldDetails that returns the name of relation and field without alias, then it search for this new name at JOINS and find allways the first one, this is wrong.

Example of select with two joins to same table
SELECT App\Entity\Product o LEFT JOIN o.productTaxons tree1 LEFT JOIN o.productTaxons tree2

Then when using a filter (Sylius\Component\Grid\Filtering\FilterInterface)

public function apply(DataSourceInterface $dataSource, string $name, $data, array $options): void { $eb = $dataSource->getExpressionBuilder(); $dataSource->restrict($eb->in('tree2.taxon', $data['product_type'])); }

But the condition goes to tree1 !! The first one.

In my case i solved it using standard Doctrine Expr, and not using grid ExpressionBuilder.

But this happens also when ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant