-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
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.