DDC-3018: DQL “NEW” Operator and Literal type "String" #3786

doctrinebot opened this Issue Mar 9, 2014 · 2 comments

2 participants


Jira issue originally created by user ehar:

Hello all,

When i use the DQL operator "new" to build data transfert object with string literal expression as field in object constructor, the call to Query::getResult thrown an exception.

Condition :
The string literal expression must be the first parameter of the constructor.

Following DQL :

$query = $em->createQuery('SELECT NEW CustomerDTO('some scalar string', c.name, c.email) FROM Customer c');

$users = $query->getResult();

Thrown exception :
ContextErrorException: Notice: Undefined variable: fieldType in doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php line 1527

That happens because in SqlWalker::walkNewObject on the AST\Literal switch case. There is no case for AST\Literal::STRING, so $fieldType isn't defined.

I have also noted if the scalar string isn't the first parameter, $fieldType take the type of previous foreach element.


Issue was closed with resolution "Fixed"


Comment created by @beberlei:

Fixed and merged into 2.4 release branch

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.4.3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment