mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-2752: Item order lost using paginator #3445
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 (Oct 20, 2013).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user krmarien:
We are using the doctrine pagination tool for faster queries in paginated results.
But doctrine is now creating the following query:
SELECT DISTINCT id0 FROM (
SELECT c0_.id AS id0, c0_.number AS number1
FROM cudi.stock_orders_items c0_
INNER JOIN cudi.stock_orders c1_ ON c0_.order_id = c1_.id
WHERE c1_.date_ordered IS NOT NULL AND c1_.date_ordered > $1 AND c1_.date_ordered < $2
ORDER BY c1_.date_ordered DESC
) dctrn_result LIMIT 25 OFFSET 50
But due to the distinct, the order is lost and the results are not sorted by date_ordered anymore. How can this be solved?
Thanks
@doctrinebot commented on GitHub (Oct 20, 2013):
Comment created by @ocramius:
[~cyberwolf] is the order lost already in this result or in the
WHERE IN()subsequent query?@doctrinebot commented on GitHub (Oct 20, 2013):
Comment created by krmarien:
I was digging in the paginator code and this is the query used to select the ids in \Doctrine\ORM\Tools\Pagination\Paginator (line 173)
The subquery from above, outputs the results in the right order. But after applying the distinct the order is messed up. I think this problem needs to be solved by the preserveSqlOrdering function in LimitSubqueryOutputWalker. But this function doesn't add a column to sort on...
@doctrinebot commented on GitHub (Oct 26, 2013):
Comment created by @beberlei:
[~krmarien] Since you have the example already, so you mean the ORDER BY has to be part of the subquery and ALSO added to the outer query? That actually makes sense.
@doctrinebot commented on GitHub (Oct 28, 2013):
Comment created by krmarien:
That would solve the problem for me.
@doctrinebot commented on GitHub (Nov 20, 2013):
Comment created by krmarien:
Any progress on this issue?
@doctrinebot commented on GitHub (Dec 4, 2013):
Comment created by krmarien:
I have found another query with the same problem. The common thing they have is that I want to order on a column of a joined entity.
@doctrinebot commented on GitHub (Dec 6, 2013):
Comment created by krmarien:
After digging in the code I found that I just had to add the joined entity to my select statement. This issue can be closed
@doctrinebot commented on GitHub (Dec 13, 2013):
Issue was closed with resolution "Won't Fix"