mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
LimitSubqueryOutputWalker used @ Paginator does not order properly #6069
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 @wucdbm on GitHub (Sep 24, 2018).
Bug Report
I believe LimitSubqueryOutputWalker::preserveSqlOrdering is still broken when there are no WHERE clauses on a related table - Ordering is not right.
Summary
The generated SQL of preserveSqlOrdering uses DISTINCT, which as far as I understand is considered an aggregate function, and in MySQL 5.7.5+ with ONLY_FULL_GROUP_BY enabled by default it leads to unexpected behaviour
Still unsure whether it's ONLY_FULL_GROUP_BY in particular causing this, but the first time I experienced it was when we upgraded to 5.7.5+
Basically, the code I proposed which was later used in another PR for the final implementation in 2.6 still has this problem.
EDIT: Results are SELECTED in the wrong order, but the displayed result subset is ordered properly, eg:
For a table with records with PK 1-50
selected results will be 1-20 going from 20 to 1 even if desired order is DESC 50 and down
Current behavior
SELECT fields FROM entity JOIN several relations ORDER BY entity.PRIMARY_KEY DESC would not give you the most recent records of entity, and will still have them ordered ASC
SELECT fields FROM entity JOIN several relations WHERE relation.something = :someValue ORDER BY entity.PK DESC would work just fine and will have the results ordered properly
How to reproduce
Create two entities
For example, Reservation and ReservationStatus where each Reservation has a status
Results are still be ordered arbitrarily, I guess mysql decides on that because of DISTINCT usage
Results are now be ordered DESC properly
Expected behavior
Ordering should be DESC in both cases
@wucdbm commented on GitHub (Mar 11, 2021):
Does not seem to be the case with recent versions of Doctrine, closing