1
0
mirror of synced 2025-01-18 06:21:40 +03:00

fix DDC-2205

This commit is contained in:
Fabio B. Silva 2012-12-20 23:06:30 -02:00
parent 4bbfe0ce8a
commit 2104ae9935
2 changed files with 34 additions and 0 deletions

View File

@ -1792,6 +1792,9 @@ class Parser
switch (true) {
case ($lookahead === Lexer::T_INTEGER):
case ($lookahead === Lexer::T_FLOAT):
// SimpleArithmeticExpression : (- u.value ) or ( + u.value ) or ( - 1 ) or ( + 1 )
case ($lookahead === Lexer::T_MINUS):
case ($lookahead === Lexer::T_PLUS):
return $this->SimpleArithmeticExpression();
case ($lookahead === Lexer::T_STRING):

View File

@ -1230,6 +1230,37 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
);
}
/**
* @group DDC-2205
*/
public function testCaseNegativeValuesInThenExpression()
{
$this->assertSqlGeneration(
"SELECT CASE g.name WHEN 'admin' THEN - 1 ELSE - 2 END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT CASE c0_.name WHEN 'admin' THEN -1 ELSE -2 END AS sclr0 FROM cms_groups c0_"
);
$this->assertSqlGeneration(
"SELECT CASE g.name WHEN 'admin' THEN - 2 WHEN 'guest' THEN - 1 ELSE 0 END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT CASE c0_.name WHEN 'admin' THEN -2 WHEN 'guest' THEN -1 ELSE 0 END AS sclr0 FROM cms_groups c0_"
);
$this->assertSqlGeneration(
"SELECT CASE g.name WHEN 'admin' THEN (- 1) ELSE (- 2) END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT CASE c0_.name WHEN 'admin' THEN -1 ELSE -2 END AS sclr0 FROM cms_groups c0_"
);
$this->assertSqlGeneration(
"SELECT CASE g.name WHEN 'admin' THEN ( - :value) ELSE ( + :value) END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT CASE c0_.name WHEN 'admin' THEN -? ELSE +? END AS sclr0 FROM cms_groups c0_"
);
$this->assertSqlGeneration(
"SELECT CASE g.name WHEN 'admin' THEN ( - g.id) ELSE ( + g.id) END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT CASE c0_.name WHEN 'admin' THEN -c0_.id ELSE +c0_.id END AS sclr0 FROM cms_groups c0_"
);
}
/**
* @group DDC-1339
*/