Permalink
Browse files

Added test to check query with ORDER BY and SQLServerPlatform

  • Loading branch information...
1 parent 2842c25 commit 6a7a625af91e8cf642cd8df96f5b538402a14488 Norbert Orzechowicz committed Feb 26, 2013
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php
@@ -41,5 +41,23 @@ public function testCountQuery_Having()
"SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id1 FROM (SELECT count(u0_.id) AS sclr0, g1_.id AS id1, u0_.id AS id2 FROM groups g1_ LEFT JOIN user_group u2_ ON g1_.id = u2_.group_id LEFT JOIN User u0_ ON u0_.id = u2_.user_id GROUP BY g1_.id HAVING sclr0 > 0) dctrn_result) dctrn_table", $query->getSql()
);
}
+
+ public function testCountQueryOrderBySqlServer()
+ {
+ $odp = $this->entityManager->getConnection()->getDatabasePlatform();
+ $this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\SQLServerPlatform());
+
+ $query = $this->entityManager->createQuery(
+ 'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p ORDER BY p.id');
+ $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker');
+ $query->setFirstResult(null)->setMaxResults(null);
+
+ $this->assertEquals(
+ "SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id0 FROM (SELECT b0_.id AS id0, b0_.author_id AS author_id1, b0_.category_id AS category_id2 FROM BlogPost b0_ WITH (NOLOCK)) dctrn_result) dctrn_table",
+ $query->getSql()
+ );
+
+ $this->entityManager->getConnection()->setDatabasePlatform($odp);
+ }
}

0 comments on commit 6a7a625

Please sign in to comment.