Doctrine select with null

Fie*_*Cat 6 php symfony doctrine-orm

是否有可能执行以下操作:

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

并避免:

Doctrine\ORM\Query\QueryException: ... got 'NULL'
Run Code Online (Sandbox Code Playgroud)

小智 2

https://github.com/doctrine/orm/issues/1670#issuecomment-591495663的解决方法:选择NULLIF(1,1) AS ...而不是NULL AS ...