Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #563 from FabioBatSilva/DDC-2268

DDC-2268 - Regression test
  • Loading branch information...
commit 1627fc95965a3e2e3894fcf7e524eb0eaa9d0ddd 2 parents 3d1956d + 452e691
@guilhermeblanco guilhermeblanco authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
View
21 tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
@@ -1866,6 +1866,27 @@ public function testCaseThenParameterArithmeticExpression()
'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'
);
}
+
+ /**
+ * @group DDC-2268
+ */
+ public function testCaseThenFunction()
+ {
+ $this->assertSqlGeneration(
+ 'SELECT CASE WHEN LENGTH(u.name) <> 0 THEN CONCAT(u.id, u.name) ELSE u.id END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u',
+ 'SELECT CASE WHEN LENGTH(c0_.name) <> 0 THEN c0_.id || c0_.name ELSE c0_.id END AS sclr0 FROM cms_users c0_'
+ );
+
+ $this->assertSqlGeneration(
+ 'SELECT CASE WHEN LENGTH(u.name) <> LENGTH(TRIM(u.name)) THEN TRIM(u.name) ELSE u.name END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u',
+ 'SELECT CASE WHEN LENGTH(c0_.name) <> LENGTH(TRIM(c0_.name)) THEN TRIM(c0_.name) ELSE c0_.name END AS sclr0 FROM cms_users c0_'
+ );
+
+ $this->assertSqlGeneration(
+ 'SELECT CASE WHEN LENGTH(u.name) > :value THEN SUBSTRING(u.name, 0, :value) ELSE TRIM(u.name) END AS name FROM Doctrine\Tests\Models\CMS\CmsUser u',
+ 'SELECT CASE WHEN LENGTH(c0_.name) > ? THEN SUBSTRING(c0_.name FROM 0 FOR ?) ELSE TRIM(c0_.name) END AS sclr0 FROM cms_users c0_'
+ );
+ }
}
class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode
Please sign in to comment.
Something went wrong with that request. Please try again.