Skip to content


DDC-2539: ResultVariable cannot be used in Like expressions #3263

doctrinebot opened this Issue · 3 comments

2 participants


Jira issue originally created by user sergei:

It is not possible to use ResultVariable in a like expression. For exemple :

$qb ->select('c', 'SQRT( AS test')
->from('SomeClass', 'c')
->having('test LIKE \'%4%\'');

return [Syntax Error] line 0, col 91: Error: Expected Literal, got 'LIKE'

$qb ->select('c')
->from('SomeClass', 'c')
->having(' LIKE \'%4%\'');

works, and :

$qb ->select('c', 'SQRT( AS test')
->from('SomeClass', 'c')
->having('test = 4');


Changing Doctrine\ORM\Query\Parser LikeExpression function fix the problem (but has maby other consequences) :

by replacing : "$stringExpr = $this->StringExpression();"
by :
$peek = $this->_lexer->glimpse();
if($peek['value'] == 'LIKE') { // Simple Expression
$stringExpr = $this->ArithmeticExpression();
} else {
$stringExpr = $this->StringExpression();


Comment created by sergei:

After working on this issue, i really think it's a bug. I just add more details on the description


Comment created by @ocramius:

Duplicate of DDC-2615 (solved in master)


Issue was closed with resolution "Duplicate"

@Ocramius Ocramius was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.4 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.