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

Closed
doctrinebot opened this Issue Jul 2, 2013 · 3 comments

2 participants

@doctrinebot

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

@doctrinebot

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

Comment created by @ocramius:

Duplicate of DDC-2615 (solved in master)

@doctrinebot

Issue was closed with resolution "Duplicate"

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.4 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