Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
DDC-2220: Add joins to Collection Filtering API #2918
Jira issue originally created by user deatheriam:
The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lacks joins. Look at the next two snippets:
This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:
That would not work.
Ideally we should have a possibility to join other entities, the Category entity in our case here:
What do you think about it, does it make sense to add such functionality?
@beberlei Would it be possible to provide an alternative?
It might not even be necessary to define a
$expr = Criteria::expr(); $criteria = Criteria::create(); return $criteria->where( $expr->andX( $expr->eq('status', 'active'), $expr->eq('supplier.status', 'active') ) );
In this case association behind supplier will be joined automatically.
When using the library rulzerz they are doing autowiring, e.g.
The responsible code:
The same would be great for this example:
$criteria = [ 'id' => 33, 'status' => 'active', 'supplier.status' => 'active' ]; /** @var Product $product */ $product = $repository->findOneBy($criteria);