Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[DDC-2205] Fix DDC-2205 #542

Merged
merged 1 commit into from

3 participants

Fabio B. Silva doctrinebot Guilherme Blanco
doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2212

Guilherme Blanco guilhermeblanco merged commit 8b5e4a9 into from
Fabio B. Silva FabioBatSilva deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 21, 2012
  1. Fabio B. Silva

    fix DDC-2205

    FabioBatSilva authored
This page is out of date. Refresh to see the latest.
3  lib/Doctrine/ORM/Query/Parser.php
View
@@ -1792,6 +1792,9 @@ public function ScalarExpression()
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):
31 tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
View
@@ -1231,6 +1231,37 @@ public function testSimpleCaseWithStringPrimary()
}
/**
+ * @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
*/
public function testIdentityFunctionInSelectClause()
Something went wrong with that request. Please try again.