Merge pull request #540 from FabioBatSilva/DDC-2208
[DDC-2208] Fix DDC-2208
This commit is contained in:
commit
6f5948746e
@ -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,27 @@ 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.salary <= :value THEN e.salary - :value WHEN e.salary >= :value THEN :value - e.salary ELSE 0 END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e',
|
||||
'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary 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.salary <= :value THEN e.salary - :value WHEN e.salary >= :value THEN :value - e.salary ELSE e.salary + 0 END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e',
|
||||
'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary ELSE c0_.salary + 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.salary <= :value THEN (e.salary - :value) WHEN e.salary >= :value THEN (:value - e.salary) ELSE (e.salary + :value) END) FROM Doctrine\Tests\Models\Company\CompanyEmployee e',
|
||||
'SELECT SUM(CASE WHEN c0_.salary <= ? THEN c0_.salary - ? WHEN c0_.salary >= ? THEN ? - c0_.salary ELSE c0_.salary + ? 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