The Doctrine ORM integration contains an alias resolver. The alias resolver tries to guess an alias of DQL paths given without an explicit alias.
For example, if we create a QueryBuilder of Product entity, and try to sort by the name DQL path, the alias resolver will try to add correct Product alias to the name, e.g. product.name.
If we provide multiple selects inside a single select() / addSelect() call, this completely breaks the alias resolver:
$queryBuilder = $productRepository->createQueryBuilder('product')
->select('product.id AS foo, COUNT(commercialGroupSchedules.id) as bar')
;
In above example, the alias resolver is trying to add root alias to the "foo" and "bar", which is incorrect. Temporarily, the workaround is to provide a single select per call:
$queryBuilder = $productRepository->createQueryBuilder('product')
->select('product.id AS foo')
->addSelect('COUNT(commercialGroupSchedules.id) as bar')
;
The Doctrine ORM integration contains an alias resolver. The alias resolver tries to guess an alias of DQL paths given without an explicit alias.
For example, if we create a QueryBuilder of
Product
entity, and try to sort by thename
DQL path, the alias resolver will try to add correctProduct
alias to thename
, e.g.product.name
.If we provide multiple selects inside a single
select()
/addSelect()
call, this completely breaks the alias resolver:In above example, the alias resolver is trying to add root alias to the "foo" and "bar", which is incorrect. Temporarily, the workaround is to provide a single select per call: