[PR #298] [MERGED] Pagination using SQL walkers #7996

Closed
opened 2026-01-22 15:57:52 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/298
Author: @sandermarechal
Created: 3/6/2012
Status: Merged
Merged: 3/12/2012
Merged by: @beberlei

Base: masterHead: paginate-sql-walkers


📝 Commits (8)

  • edd5d14 Pagination using SQL walkers
  • d2501a9 Throw exception when using the CountWalker with a HAVING query
  • 2f817b3 Use a dataProvider to test both TreeWalker and SqlWalker pagination
  • c9d962b Fix indentation
  • ad871e8 Cleaned up use statements
  • 47964a1 Use assertCount for simpler tests
  • 53ff312 Renamed *SqlWalker to *OutputWalker
  • 43f97a9 CountOutputWalker does not need CountWalker::HINT_DISTINCT

📊 Changes

10 files changed (+531 additions, -64 deletions)

View changed files

lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php (+120 -0)
📝 lib/Doctrine/ORM/Tools/Pagination/CountWalker.php (+4 -0)
lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php (+144 -0)
📝 lib/Doctrine/ORM/Tools/Pagination/Paginator.php (+65 -12)
📝 tests/Doctrine/Tests/ORM/Functional/PaginationTest.php (+76 -24)
tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php (+45 -0)
📝 tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php (+26 -10)
tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php (+33 -0)
📝 tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php (+4 -4)
📝 tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php (+14 -14)

📄 Description

A CountSqlWalker and LimitSubquerySqlWalker have been implemented. By
default the Paginator will use these SQL walkers. When a query already
uses custom SQL walkers, the Paginator will fall back to the existing
TreeWalker implementations. Improvements:

  • Support for more complex DQL queries using named mixed results with
    GROUP BY and HAVING. For example:

    SELECT g, u, COUNT(u.id) AS userCount
    FROM Entity\Group g LEFT JOIN g.users u
    GROUP BY g.id
    HAVING userCount > 0

  • Support for entities with composite primary keys in the CountSqlWalker
    and LimitSubquerySqlWalker. Only the WhereInWalker still needs to be
    updated for full composite primary key support. But someone smarter
    than me needs to look at that and figure out how to build a WHERE IN
    query that can select rows based on multiple columns.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/298 **Author:** [@sandermarechal](https://github.com/sandermarechal) **Created:** 3/6/2012 **Status:** ✅ Merged **Merged:** 3/12/2012 **Merged by:** [@beberlei](https://github.com/beberlei) **Base:** `master` ← **Head:** `paginate-sql-walkers` --- ### 📝 Commits (8) - [`edd5d14`](https://github.com/doctrine/orm/commit/edd5d14b06f03187bc512c8c1c066539ee3ceed0) Pagination using SQL walkers - [`d2501a9`](https://github.com/doctrine/orm/commit/d2501a9e4a43126c8ac65ce91d56849d1d205610) Throw exception when using the CountWalker with a HAVING query - [`2f817b3`](https://github.com/doctrine/orm/commit/2f817b30c3290d6fe1b4d53a0c186c61ac8a803c) Use a dataProvider to test both TreeWalker and SqlWalker pagination - [`c9d962b`](https://github.com/doctrine/orm/commit/c9d962b12ad9911a1ab5167c6e2e5bf2a785b141) Fix indentation - [`ad871e8`](https://github.com/doctrine/orm/commit/ad871e8b266f49b9b551a7cc25d474704ca5bdf5) Cleaned up `use` statements - [`47964a1`](https://github.com/doctrine/orm/commit/47964a1605b7c39791d998df6ad9a87fdf5d45f5) Use `assertCount` for simpler tests - [`53ff312`](https://github.com/doctrine/orm/commit/53ff31293643d5884c3b705066f4cb5fe32832cf) Renamed *SqlWalker to *OutputWalker - [`43f97a9`](https://github.com/doctrine/orm/commit/43f97a9abc0780d81d1cff92fcac3d331d629284) CountOutputWalker does not need CountWalker::HINT_DISTINCT ### 📊 Changes **10 files changed** (+531 additions, -64 deletions) <details> <summary>View changed files</summary> ➕ `lib/Doctrine/ORM/Tools/Pagination/CountOutputWalker.php` (+120 -0) 📝 `lib/Doctrine/ORM/Tools/Pagination/CountWalker.php` (+4 -0) ➕ `lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php` (+144 -0) 📝 `lib/Doctrine/ORM/Tools/Pagination/Paginator.php` (+65 -12) 📝 `tests/Doctrine/Tests/ORM/Functional/PaginationTest.php` (+76 -24) ➕ `tests/Doctrine/Tests/ORM/Tools/Pagination/CountOutputWalkerTest.php` (+45 -0) 📝 `tests/Doctrine/Tests/ORM/Tools/Pagination/CountWalkerTest.php` (+26 -10) ➕ `tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php` (+33 -0) 📝 `tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryWalkerTest.php` (+4 -4) 📝 `tests/Doctrine/Tests/ORM/Tools/Pagination/WhereInWalkerTest.php` (+14 -14) </details> ### 📄 Description A CountSqlWalker and LimitSubquerySqlWalker have been implemented. By default the Paginator will use these SQL walkers. When a query already uses custom SQL walkers, the Paginator will fall back to the existing TreeWalker implementations. Improvements: - Support for more complex DQL queries using named mixed results with GROUP BY and HAVING. For example: SELECT g, u, COUNT(u.id) AS userCount FROM Entity\Group g LEFT JOIN g.users u GROUP BY g.id HAVING userCount > 0 - Support for entities with composite primary keys in the CountSqlWalker and LimitSubquerySqlWalker. Only the WhereInWalker still needs to be updated for full composite primary key support. But someone smarter than me needs to look at that and figure out how to build a WHERE IN query that can select rows based on multiple columns. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 15:57:52 +01:00
admin closed this issue 2026-01-22 15:57:52 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7996