Skip to content

Commit 72ae7f5

Browse files
flip111Philippe Lagas
authored and
Philippe Lagas
committed
Changed GroupBy alias to real column name for all platforms and adjusted failing test accordingly. Has fallback in cases where real column name is not possible (example: Doctrine\Tests\ORM\Query\SelectSqlGenerationTest::testGroupBySupportsIdentificationVariable)
1 parent 76fda95 commit 72ae7f5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/Doctrine/ORM/Query/SqlWalker.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use Doctrine\DBAL\LockMode;
2323
use Doctrine\DBAL\Types\Type;
24-
use Doctrine\DBAL\Platforms\SQLServerPlatform;
2524
use Doctrine\ORM\Mapping\ClassMetadata;
2625
use Doctrine\ORM\Query;
2726
use Doctrine\ORM\Query\QueryException;
@@ -1625,7 +1624,9 @@ public function walkGroupByItem($groupByItem)
16251624

16261625
// ResultVariable
16271626
if (isset($this->queryComponents[$groupByItem]['resultVariable'])) {
1628-
if ($this->platform instanceof SQLServerPlatform) {
1627+
if ($this->queryComponents[$groupByItem]['resultVariable'] instanceof AST\PathExpression) {
1628+
return $this->walkPathExpression($this->queryComponents[$groupByItem]['resultVariable']);
1629+
} elseif (isset($this->queryComponents[$groupByItem]['resultVariable']->pathExpression)) {
16291630
return $this->walkPathExpression($this->queryComponents[$groupByItem]['resultVariable']->pathExpression);
16301631
} else {
16311632
return $this->walkResultVariable($groupByItem);

tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ public function testGroupBySupportsResultVariable()
15731573
{
15741574
$this->assertSqlGeneration(
15751575
'SELECT u, u.status AS st FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY st',
1576-
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.status AS status4 FROM cms_users c0_ GROUP BY status4'
1576+
'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c0_.status AS status4 FROM cms_users c0_ GROUP BY c0_.status'
15771577
);
15781578
}
15791579

@@ -2257,4 +2257,3 @@ public function setValue($value)
22572257
}
22582258

22592259
}
2260-

0 commit comments

Comments
 (0)