Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[DDC-2205] Fix DDC-2205 #542

Merged
merged 1 commit into from over 1 year ago

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

Showing 1 unique commit by 1 author.

Dec 21, 2012
Fabio B. Silva FabioBatSilva fix DDC-2205 2104ae9
This page is out of date. Refresh to see the latest.
3  lib/Doctrine/ORM/Query/Parser.php
@@ -1792,6 +1792,9 @@ public function ScalarExpression()
1792 1792 switch (true) {
1793 1793 case ($lookahead === Lexer::T_INTEGER):
1794 1794 case ($lookahead === Lexer::T_FLOAT):
  1795 + // SimpleArithmeticExpression : (- u.value ) or ( + u.value ) or ( - 1 ) or ( + 1 )
  1796 + case ($lookahead === Lexer::T_MINUS):
  1797 + case ($lookahead === Lexer::T_PLUS):
1795 1798 return $this->SimpleArithmeticExpression();
1796 1799
1797 1800 case ($lookahead === Lexer::T_STRING):
31 tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
@@ -1231,6 +1231,37 @@ public function testSimpleCaseWithStringPrimary()
1231 1231 }
1232 1232
1233 1233 /**
  1234 + * @group DDC-2205
  1235 + */
  1236 + public function testCaseNegativeValuesInThenExpression()
  1237 + {
  1238 + $this->assertSqlGeneration(
  1239 + "SELECT CASE g.name WHEN 'admin' THEN - 1 ELSE - 2 END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
  1240 + "SELECT CASE c0_.name WHEN 'admin' THEN -1 ELSE -2 END AS sclr0 FROM cms_groups c0_"
  1241 + );
  1242 +
  1243 + $this->assertSqlGeneration(
  1244 + "SELECT CASE g.name WHEN 'admin' THEN - 2 WHEN 'guest' THEN - 1 ELSE 0 END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
  1245 + "SELECT CASE c0_.name WHEN 'admin' THEN -2 WHEN 'guest' THEN -1 ELSE 0 END AS sclr0 FROM cms_groups c0_"
  1246 + );
  1247 +
  1248 + $this->assertSqlGeneration(
  1249 + "SELECT CASE g.name WHEN 'admin' THEN (- 1) ELSE (- 2) END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
  1250 + "SELECT CASE c0_.name WHEN 'admin' THEN -1 ELSE -2 END AS sclr0 FROM cms_groups c0_"
  1251 + );
  1252 +
  1253 + $this->assertSqlGeneration(
  1254 + "SELECT CASE g.name WHEN 'admin' THEN ( - :value) ELSE ( + :value) END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
  1255 + "SELECT CASE c0_.name WHEN 'admin' THEN -? ELSE +? END AS sclr0 FROM cms_groups c0_"
  1256 + );
  1257 +
  1258 + $this->assertSqlGeneration(
  1259 + "SELECT CASE g.name WHEN 'admin' THEN ( - g.id) ELSE ( + g.id) END FROM Doctrine\Tests\Models\CMS\CmsGroup g",
  1260 + "SELECT CASE c0_.name WHEN 'admin' THEN -c0_.id ELSE +c0_.id END AS sclr0 FROM cms_groups c0_"
  1261 + );
  1262 + }
  1263 +
  1264 + /**
1234 1265 * @group DDC-1339
1235 1266 */
1236 1267 public function testIdentityFunctionInSelectClause()

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.