mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3448: @OrderBy on eager @OneToMany does not work #4253
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Dec 13, 2014).
Jira issue originally created by user backbone:
generated code when eagerly fetching:
when fetching lazy the collection query has the ORDER BY clause
@guilhermeblanco commented on GitHub (May 19, 2016):
Copied from #3885: It's not an easy solution, because ordering needs only to apply for the association, not for the top-level entities though. This would require the join to not happen as part of main query, but immediately after.
@aistis- commented on GitHub (Oct 20, 2016):
Run into the same problem. Does anyone has any workaround for this?
EDIT: found a work around http://stackoverflow.com/questions/16705425/usort-a-doctrine-common-collections-arraycollection#answer-24246304
@Ocramius commented on GitHub (Oct 25, 2016):
Current workaround is multi-step hydration - https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/
Not fun, not simple, but works and is fairly efficient.
@quisse commented on GitHub (Feb 18, 2019):
Any update on this?
@beberlei commented on GitHub (Feb 16, 2020):
This might be fixed by https://github.com/doctrine/orm/pull/7850 but never got a reference.
@secit-pl commented on GitHub (Jul 24, 2023):
The problem still exists:
Here all elements are sorted by position:
here "position" is ignored and all fields are sorted by primary key:
Used packages:
doctrine/orm - 2.9.6
doctrine/doctrine-bundle - 2.5.7
doctrine/annotations - 1.14.3
@derrabus commented on GitHub (Jul 24, 2023):
That release is almost two years old. I guess that does not really count as "still exists". 😉
@krugerman007 commented on GitHub (Aug 20, 2023):
What about updates?
doctrine/orm - 2.16.1 - problem exists :(
@schwierBD commented on GitHub (Nov 9, 2023):
Any Update?
@oleg-andreyev commented on GitHub (Mar 5, 2024):
Fix looks like quite easy:
\Doctrine\ORM\UnitOfWork::eagerLoadCollections
when calling loadAll, just pass
orderBymapping.¯_(ツ)_/¯
@krugerman007 commented on GitHub (Feb 26, 2025):
We are still waiting for a fix :/(