Closed
Description
I recently migrated our project from doctrine v2.5.6 to v2.6.1. and ran into an error saying:
Expected StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression, got 'MAX'
… with the query being:
$QB = $this->_em->createQueryBuilder();
$QB ->addSelect("CONCAT(t2.dagId, MAX(t1.executionDate))")
->from(TaskInstance::class, 't1')
->join('t1.dag', 't2')
->addGroupBy('t2.dagId')
;
// Calling either getResults() or getSQL raises the error.
print_r($QB->getQuery()->getSQL());
After looking at Doctrine\ORM\Query\Parser::StringPrimary()
, I ended up nesting MAX(…)
call within a IF
to fix the error:
$QB ->addSelect("CONCAT(t2.dagId, IF(1=1, MAX(t1.executionDate)))")
Is such a call rejection normal/intended or should this problem be addressed ?