Skip to content

Commit 8ef5c80

Browse files
authored
Merge pull request doctrine#10974 from beberlei/RemovePartialObjectExpressionUsage
2 parents 3ff67c3 + 083b1f9 commit 8ef5c80

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Doctrine\ORM\OptimisticLockException;
1616
use Doctrine\ORM\Query;
1717
use Doctrine\ORM\Query\AST\OrderByClause;
18-
use Doctrine\ORM\Query\AST\PartialObjectExpression;
1918
use Doctrine\ORM\Query\AST\PathExpression;
2019
use Doctrine\ORM\Query\AST\SelectExpression;
2120
use Doctrine\ORM\Query\AST\SelectStatement;
@@ -335,7 +334,7 @@ private function addMissingItemsFromOrderByToSelect(SelectStatement $AST): void
335334

336335
// Add select items which were not excluded to the AST's select clause.
337336
foreach ($selects as $idVar => $fields) {
338-
$AST->selectClause->selectExpressions[] = new SelectExpression(new PartialObjectExpression($idVar, array_keys($fields)), null, true);
337+
$AST->selectClause->selectExpressions[] = new SelectExpression($idVar, null, true);
339338
}
340339
}
341340

@@ -374,8 +373,7 @@ private function recreateInnerSql(
374373
string $innerSql
375374
): string {
376375
[$searchPatterns, $replacements] = $this->generateSqlAliasReplacements();
377-
378-
$orderByItems = [];
376+
$orderByItems = [];
379377

380378
foreach ($orderByClause->orderByItems as $orderByItem) {
381379
// Walk order by item to get string representation of it and

tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function testCountQueryWithArithmeticOrderByCondition(): void
229229
);
230230
}
231231

232-
public function testCountQueryWithComplexScalarOrderByItem(): void
232+
public function testCountQueryWithComplexScalarOrderByItemWithoutJoin(): void
233233
{
234234
$query = $this->entityManager->createQuery(
235235
'SELECT a FROM Doctrine\Tests\ORM\Tools\Pagination\Avatar a ORDER BY a.imageHeight * a.imageWidth DESC'
@@ -244,7 +244,7 @@ public function testCountQueryWithComplexScalarOrderByItem(): void
244244
);
245245
}
246246

247-
public function testCountQueryWithComplexScalarOrderByItemJoined(): void
247+
public function testCountQueryWithComplexScalarOrderByItemJoinedWithoutPartial(): void
248248
{
249249
$query = $this->entityManager->createQuery(
250250
'SELECT u FROM Doctrine\Tests\ORM\Tools\Pagination\User u JOIN u.avatar a ORDER BY a.imageHeight * a.imageWidth DESC'
@@ -254,7 +254,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoined(): void
254254
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class);
255255

256256
self::assertSame(
257-
'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_1 * imageWidth_2 FROM (SELECT u0_.id AS id_0, a1_.imageHeight AS imageHeight_1, a1_.imageWidth AS imageWidth_2, a1_.user_id AS user_id_3 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_1 * imageWidth_2 DESC) dctrn_result',
257+
'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.image AS image_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.imageAltDesc AS imageAltDesc_5, a1_.user_id AS user_id_6 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result',
258258
$query->getSQL()
259259
);
260260
}
@@ -269,7 +269,7 @@ public function testCountQueryWithComplexScalarOrderByItemJoinedWithPartial(): v
269269
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class);
270270

271271
self::assertSame(
272-
'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_3 * imageWidth_4 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.imageHeight AS imageHeight_3, a1_.imageWidth AS imageWidth_4, a1_.user_id AS user_id_5 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_3 * imageWidth_4 DESC) dctrn_result',
272+
'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, imageHeight_5 * imageWidth_6 FROM (SELECT u0_.id AS id_0, a1_.id AS id_1, a1_.imageAltDesc AS imageAltDesc_2, a1_.id AS id_3, a1_.image AS image_4, a1_.imageHeight AS imageHeight_5, a1_.imageWidth AS imageWidth_6, a1_.imageAltDesc AS imageAltDesc_7, a1_.user_id AS user_id_8 FROM User u0_ INNER JOIN Avatar a1_ ON u0_.id = a1_.user_id) dctrn_result_inner ORDER BY imageHeight_5 * imageWidth_6 DESC) dctrn_result',
273273
$query->getSQL()
274274
);
275275
}
@@ -328,7 +328,7 @@ public function testLimitSubqueryWithOrderByInnerJoined(): void
328328
$query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, LimitSubqueryOutputWalker::class);
329329

330330
self::assertSame(
331-
'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_1 FROM (SELECT b0_.id AS id_0, a1_.name AS name_1, b0_.author_id AS author_id_2, b0_.category_id AS category_id_3 FROM BlogPost b0_ INNER JOIN Author a1_ ON b0_.author_id = a1_.id) dctrn_result_inner ORDER BY name_1 ASC) dctrn_result',
331+
'SELECT DISTINCT id_0 FROM (SELECT DISTINCT id_0, name_2 FROM (SELECT b0_.id AS id_0, a1_.id AS id_1, a1_.name AS name_2, b0_.author_id AS author_id_3, b0_.category_id AS category_id_4 FROM BlogPost b0_ INNER JOIN Author a1_ ON b0_.author_id = a1_.id) dctrn_result_inner ORDER BY name_2 ASC) dctrn_result',
332332
$query->getSQL()
333333
);
334334
}

0 commit comments

Comments
 (0)