[DDC-1800] Paginator results is wrong if your query use order by clause Created: 27/Apr/12 Updated: 09/Apr/13 Resolved: 29/Aug/12 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | 2.2.4, 2.3 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Marc Drolet | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux oracle |
||
| Description |
|
NOTE: I didn't try this on other database, I'm using Oracle. if my original fetchJoin query use an order by clause, the results is not keeping the provided order by clause and re-order them by id. here is my generated query to get the distinct records that get generated: SELECT distinct ID0 running this query I get the id 30, 44 when the inner query return 44, 30 here is the query that should get generated to take care of the order by clause: To fix this on the Paginator code: file: ORM/Tools/Pagination/LimitSubqueryOutputWalker.php change: for: |
| Comments |
| Comment by Marc Drolet [ 14/May/12 ] |
|
rownum instead of numrow. sorry. $sql = sprintf('SELECT b.*, rownum as rn FROM (SELECT DISTINCT %s, rownum FROM (%s) ORDER BY rownum ASC) b', |
| Comment by Benjamin Eberlei [ 07/Jul/12 ] |
|
Doctrine 2.2.2 doesnt have the LimitSubqueryoutputWalker and Doctrine 2.3-dev does not have the line in the code. Can you make a more explicit statement of where the change is necessary? |
| Comment by Marc Drolet [ 09/Jul/12 ] |
|
It's in the Pagination of version 2.2.2. ORM/Tools/Pagination/LimitSubqueryOutputWalker.php |
| Comment by Benjamin Eberlei [ 09/Jul/12 ] |
|
This is the 2.2 branch, https://github.com/doctrine/doctrine2/tree/2.2/lib/Doctrine/ORM/Tools/Pagination and https://github.com/doctrine/doctrine2/tree/2.2.2/lib/Doctrine/ORM/Tools/Pagination is the 2.2.2 tag. no LimitSubqueryOutputWalker.php in there. |
| Comment by Benjamin Eberlei [ 29/Aug/12 ] |
|
Fixed |
| Comment by Raymond Kolbe [ 09/Apr/13 ] |
|
This issue is popping it's head up again! Benjamin, your tests don't test for the ordering problem unless those tests are happening somewhere else? https://github.com/doctrine/doctrine2/commit/f55b5411c8b1f75bf2b5cf5ffe4bc50034fb91cb I am performing a query as complex as Marc's and I experience the same exact issue. I have checked out today's latest master branch as well as the 2.3 tag with no change. Please advise. |
| Comment by Raymond Kolbe [ 09/Apr/13 ] |
|
I have a PR in https://github.com/doctrine/doctrine2/pull/645 |