1
0
mirror of synced 2025-01-22 08:11:40 +03:00
This commit is contained in:
aleks 2013-01-27 11:09:26 +02:00
parent 6662096ed3
commit dc190a297d
2 changed files with 5 additions and 7 deletions

View File

@ -179,16 +179,14 @@ class LimitSubqueryOutputWalker extends SqlWalker
$orderBy = array(); $orderBy = array();
if (isset($AST->orderByClause)) { if (isset($AST->orderByClause)) {
foreach ($AST->orderByClause->orderByItems as $item) { foreach ($AST->orderByClause->orderByItems as $item) {
if (is_object($item->expression)) { $possibleAliases = (is_object($item->expression))
$possibleAliases = array_keys($this->rsm->fieldMappings, $item->expression->field); ? array_keys($this->rsm->fieldMappings, $item->expression->field)
} else { : array_keys($this->rsm->scalarMappings, $item->expression);
$possibleAliases = array_keys($this->rsm->scalarMappings, $item->expression);
}
foreach ($possibleAliases as $alias) { foreach ($possibleAliases as $alias) {
if (!is_object($item->expression) || $this->rsm->columnOwnerMap[$alias] == $item->expression->identificationVariable) { if (!is_object($item->expression) || $this->rsm->columnOwnerMap[$alias] == $item->expression->identificationVariable) {
$sqlOrderColumns[] = $alias; $sqlOrderColumns[] = $alias;
$orderBy[] = $alias . ' ' . $item->type; $orderBy[] = $alias . ' ' . $item->type;
break; break;
} }
} }

View File

@ -42,7 +42,7 @@ class LimitSubqueryOutputWalkerTest extends PaginationTestCase
$this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform); $this->entityManager->getConnection()->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform);
$query = $this->entityManager->createQuery( $query = $this->entityManager->createQuery(
'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\USER u JOIN u.groups g ORDER BY g_quantity' 'SELECT u, g, COUNT(g.id) AS g_quantity FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.groups g ORDER BY g_quantity'
); );
$limitQuery = clone $query; $limitQuery = clone $query;
$limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker'); $limitQuery->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker');