Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'GH-572' into 2.3

  • Loading branch information...
commit 550c1cf98c7718d151c750d37c408fa041f922f4 2 parents 304acf0 + 33799d0
Benjamin Eberlei authored March 12, 2013
4  lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php
@@ -74,6 +74,10 @@ public function __construct($query, $parserResult, array $queryComponents)
74 74
      */
75 75
     public function walkSelectStatement(SelectStatement $AST)
76 76
     {
  77
+        if ($this->platform->getName() === "mssql") {
  78
+            $AST->orderByClause = null;
  79
+        }
  80
+
77 81
         $sql = parent::walkSelectStatement($AST);
78 82
 
79 83
         // Find out the SQL alias of the identifier column of the root entity
17  tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php
@@ -41,5 +41,22 @@ public function testCountQuery_Having()
41 41
             "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()
42 42
         );
43 43
     }
  44
+
  45
+    public function testCountQueryOrderBySqlServer()
  46
+    {
  47
+        if ($this->entityManager->getConnection()->getDatabasePlatform()->getName() !== "mssql") {
  48
+            $this->markTestSkipped('SQLServer only test.');
  49
+        }
  50
+
  51
+        $query = $this->entityManager->createQuery(
  52
+            'SELECT p FROM Doctrine\Tests\ORM\Tools\Pagination\BlogPost p ORDER BY p.id');
  53
+        $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\CountOutputWalker');
  54
+        $query->setFirstResult(null)->setMaxResults(null);
  55
+
  56
+        $this->assertEquals(
  57
+            "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_) dctrn_result) dctrn_table",
  58
+            $query->getSql()
  59
+        );
  60
+    }
44 61
 }
45 62
 

0 notes on commit 550c1cf

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