Fix DDC-2208
This commit is contained in:
parent
8b5e4a9a52
commit
eda43c77bb
@ -1807,7 +1807,14 @@ class Parser
|
||||
return new AST\Literal(AST\Literal::BOOLEAN, $this->lexer->token['value']);
|
||||
|
||||
case ($lookahead === Lexer::T_INPUT_PARAMETER):
|
||||
return $this->InputParameter();
|
||||
switch (true) {
|
||||
case $this->isMathOperator($peek):
|
||||
// :param + u.value
|
||||
return $this->SimpleArithmeticExpression();
|
||||
|
||||
default:
|
||||
return $this->InputParameter();
|
||||
}
|
||||
|
||||
case ($lookahead === Lexer::T_CASE):
|
||||
case ($lookahead === Lexer::T_COALESCE):
|
||||
|
@ -1773,6 +1773,21 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
||||
'SELECT q0_."group-id" AS groupid0, q0_."group-name" AS groupname1, q1_."group-id" AS groupid2, q1_."group-name" AS groupname3 FROM "quote-group" q0_ INNER JOIN "quote-group" q1_ ON q0_."parent-id" = q1_."group-id"'
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @group DDC-2208
|
||||
*/
|
||||
public function testCaseThenParameterArithmeticExpression()
|
||||
{
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT SUM(CASE WHEN e.startDate <= :date THEN e.startDate - :date WHEN e.startDate >= :date THEN :date - e.startDate ELSE 0 END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e',
|
||||
'SELECT SUM(CASE WHEN c0_.startDate <= ? THEN c0_.startDate - ? WHEN c0_.startDate >= ? THEN ? - c0_.startDate ELSE 0 END) AS sclr0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id'
|
||||
);
|
||||
|
||||
$this->assertSqlGeneration(
|
||||
'SELECT SUM(CASE WHEN e.startDate <= :date THEN e.startDate - :date WHEN e.startDate >= :date THEN :date - e.startDate ELSE e.startDate + 0 END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e',
|
||||
'SELECT SUM(CASE WHEN c0_.startDate <= ? THEN c0_.startDate - ? WHEN c0_.startDate >= ? THEN ? - c0_.startDate ELSE c0_.startDate + 0 END) AS sclr0 FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode
|
||||
|
Loading…
x
Reference in New Issue
Block a user