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

Closed
opened 2026-01-22 14:14:50 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 2, 2013).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user sergei:

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

$qb ->select('c', 'SQRT(c.id) 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('c.id LIKE '%4%'');

works, and :

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

works

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();
}

Originally created by @doctrinebot on GitHub (Jul 2, 2013). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user sergei: It is not possible to use ResultVariable in a like expression. For exemple : $qb ->select('c', 'SQRT(c.id) 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('c.id LIKE \'%4%\''); works, and : $qb ->select('c', 'SQRT(c.id) AS test') ->from('SomeClass', 'c') ->having('test = 4'); works 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(); }
admin added the Bug label 2026-01-22 14:14:50 +01:00
admin closed this issue 2026-01-22 14:14:51 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 26, 2013):

Comment created by sergei:

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

@doctrinebot commented on GitHub (Aug 26, 2013): Comment created by sergei: After working on this issue, i really think it's a bug. I just add more details on the description
Author
Owner

@doctrinebot commented on GitHub (Aug 26, 2013):

Comment created by @ocramius:

Duplicate of DDC-2615 (solved in master)

@doctrinebot commented on GitHub (Aug 26, 2013): Comment created by @ocramius: Duplicate of [DDC-2615](http://www.doctrine-project.org/jira/browse/DDC-2615) (solved in master)
Author
Owner

@doctrinebot commented on GitHub (Aug 26, 2013):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (Aug 26, 2013): Issue was closed with resolution "Duplicate"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3187