Skip to content

Commit 100388d

Browse files
carlobeltramealanpoulain
authored andcommitted
fix: Remove unnecessary duplicate select statement
This exact select statement is already added a few lines above. The only exception is when fetchPartial is active, and in that case the current implementation is wrong anyways, because it always adds the full select. When this "temporary" solution for avoiding recursion was implemented, the duplicated line above was not yet there: https://github.com/api-platform/core/blob/5ba518014e2770e1ad5686b0124b2db45245fee5/src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php#L148 But later, the duplicated statement was added, and the select statement inside the "Avoid recursion" case was made obsolete: e34427a
1 parent 8245544 commit 100388d

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/Core/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,8 @@ private function joinRelations(QueryBuilder $queryBuilder, QueryNameGeneratorInt
268268
$queryBuilder->addSelect($associationAlias);
269269
}
270270

271-
// Avoid recursive joins
271+
// Avoid recursive joins for self-referencing relations
272272
if ($mapping['targetEntity'] === $resourceClass) {
273-
// Avoid joining the same association twice (see #1959)
274-
if (!\in_array($associationAlias, $queryBuilder->getAllAliases(), true)) {
275-
$queryBuilder->addSelect($associationAlias);
276-
}
277-
278273
continue;
279274
}
280275

0 commit comments

Comments
 (0)