Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DDC-1858 Added coverage to ticket. Functionality already implemented.

  • Loading branch information...
commit 4e99c5c127c810bf63c9a371f87f0ff5c82e3e79 1 parent 462173a
Guilherme Blanco authored
View
8 tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php
@@ -590,6 +590,14 @@ public function testCaseSupportContainingCoalesceExpression()
{
$this->assertValidDQL("select COALESCE(NULLIF(u.name, ''), u.username) as Display FROM Doctrine\Tests\Models\CMS\CmsUser u");
}
+
+ /**
+ * @gorup DDC-1858
+ */
+ public function testHavingSupportIsNullExpression()
+ {
+ $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL");
+ }
}
/** @Entity */
View
30 tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php
@@ -1916,7 +1916,7 @@ public function testSupportsMoreThanTwoParametersInConcatFunction()
{
$connMock = $this->_em->getConnection();
$orgPlatform = $connMock->getDatabasePlatform();
-
+
$connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform);
$this->assertSqlGeneration(
"SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1",
@@ -1926,7 +1926,7 @@ public function testSupportsMoreThanTwoParametersInConcatFunction()
"SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1",
"SELECT CONCAT(c0_.id, c0_.name, c0_.status) AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?"
);
-
+
$connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform);
$this->assertSqlGeneration(
"SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1",
@@ -1936,7 +1936,7 @@ public function testSupportsMoreThanTwoParametersInConcatFunction()
"SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1",
"SELECT c0_.id || c0_.name || c0_.status AS sclr0 FROM cms_users c0_ WHERE c0_.id = ?"
);
-
+
$connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SQLServerPlatform());
$this->assertSqlGeneration(
"SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, u.status, 's') = ?1",
@@ -1946,7 +1946,7 @@ public function testSupportsMoreThanTwoParametersInConcatFunction()
"SELECT CONCAT(u.id, u.name, u.status) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1",
"SELECT (c0_.id + c0_.name + c0_.status) AS sclr0 FROM cms_users c0_ WITH (NOLOCK) WHERE c0_.id = ?"
);
-
+
$connMock->setDatabasePlatform($orgPlatform);
}
@@ -1986,6 +1986,28 @@ public function testOrderByClauseShouldReplaceOrderByRelationMapping()
'SELECT r0_.id AS id0, r1_.id AS id1, r1_.passengerName AS passengerName2 FROM RoutingRoute r0_ INNER JOIN RoutingRouteBooking r1_ ON r0_.id = r1_.route_id ORDER BY r1_.passengerName DESC'
);
}
+
+ /**
+ * @group DDC-1858
+ */
+ public function testHavingSupportIsNullExpression()
+ {
+ $this->assertSqlGeneration(
+ 'SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING u.username IS NULL',
+ 'SELECT c0_.name AS name0 FROM cms_users c0_ HAVING c0_.username IS NULL'
+ );
+ }
+
+ /**
+ * @group DDC-1858
+ */
+ public function testHavingSupportResultVariableInExpression()
+ {
+ $this->assertSqlGeneration(
+ 'SELECT u.name AS foo FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING foo IN (?1)',
+ 'SELECT c0_.name AS name0 FROM cms_users c0_ HAVING name0 IN (?)'
+ );
+ }
}
class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode

4 comments on commit 4e99c5c

@tranba

@guilhermeblanco
But If DQL like this:
SELECT COUNT(u.name) countName FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING countName IS NULL
-> result: failed

@guilhermeblanco

@tranba I implemented this support in Doctrine master.
It was documented as not supported before. I updated our code and documentation to make this available, so use doctrine master in your case. =)

@tranba

@guilhermeblanco Thanks you!

@AlixBa

@guilhermeblanco Is it possible to handle the HAVING field LIKE ?
This DQL is not working and throws a QueryException SELECT COUNT(u.name) countName FROM Doctrine\Tests\Models\CMS\CmsUser u HAVING countName LIKE ?123

Please sign in to comment.
Something went wrong with that request. Please try again.