Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine select with null

Is there a possibility to execute something like:

$builder = $this->getEntityManager()->createQueryBuilder();
$builder->select(
        'f.id',
        ...
        'NULL AS missing_attribute'
    )
    ->from(..., 'f')
    ...;

And avoid:

Doctrine\ORM\Query\QueryException: ... got 'NULL'
like image 589
FieryCat Avatar asked Sep 07 '17 08:09

FieryCat


1 Answers

Workaround from https://github.com/doctrine/orm/issues/1670#issuecomment-591495663: select NULLIF(1,1) AS ... instead of NULL AS ...

like image 84
user15424515 Avatar answered Oct 15 '22 00:10

user15424515