1
0
mirror of synced 2025-01-31 04:21:44 +03:00

Update SqlWalker.php fixed wrong GROUP BY clause on SQL Server platform

Without this patch a query would like like:
```
SELECT c0_.Country AS sclr0
FROM Continent c0_ WITH (NOLOCK)
WHERE c0_.Country = 38
GROUP BY sclr0
```
Using the column alias in the GROUP BY clause. However this is not allowed on SQL Server. References:
1. http://stackoverflow.com/a/3841804
2. http://technet.microsoft.com/en-us/library/ms189499.aspx (Logical Processing Order of the SELECT statement)

The correct query should be:
```
SELECT c0_.Country AS sclr0
FROM Continent c0_ WITH (NOLOCK)
WHERE c0_.Country = 38
GROUP BY c0_.Country
```
This commit is contained in:
flip111 2013-09-26 14:11:56 +02:00
parent bd7c7ebaf3
commit 76fda9562c

View File

@ -21,6 +21,7 @@ namespace Doctrine\ORM\Query;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\QueryException;
@ -1624,7 +1625,11 @@ class SqlWalker implements TreeWalker
// ResultVariable
if (isset($this->queryComponents[$groupByItem]['resultVariable'])) {
return $this->walkResultVariable($groupByItem);
if ($this->platform instanceof SQLServerPlatform) {
return $this->walkPathExpression($this->queryComponents[$groupByItem]['resultVariable']->pathExpression);
} else {
return $this->walkResultVariable($groupByItem);
}
}
// IdentificationVariable