neos / flow-development-collection

The unified repository containing the Flow core packages, used for Flow development.
https://flow.neos.io/
MIT License
138 stars 188 forks source link

Add a option to select the joined tables for association filtering. #560

Open neos-bot opened 9 years ago

neos-bot commented 9 years ago

Jira issue originally created by user baumgartl:

If you have a hierarchy like this:

And want to filter the shows by a property of the episodes you can do this with (Repository find method):

$query = $this->createQuery();

$constraint = $query->equals('seasons.episodes.propertyName', 'operand');

$query->matching($constraint)->execute();

But if you want to get the seasons with $show->getSeaons() for this filtered list, you get ALL linked seasons. The same applies for episodes.

With the attached path, you can add all joined tables to the query select. The result will be mapped to the objects and the get seasons and get episodes method only returns the filtered entities.

Atachements:

Jira Image

Jira-URL: https://jira.neos.io/browse/FLOW-232

neos-bot commented 9 years ago

Comment created by baumgartl:

Another way is to guess the join aliases and add them to the select manually:

/*** @var Query $query **/
$queryBuilder = $query->getQueryBuilder();

$queryBuilder->addSelect('seasons0', 'episodes1');
neos-bot commented 9 years ago

Comment created by baumgartl:

I think it would be generally worthy if we had the possibility to add associations (join tables) to a query without to know the table aliases.

neos-bot commented 8 years ago

Comment created by lubitz:

+1 from me. Doctrine already supports that, so why not the flow query interface?