[API] Enforce pk ordering for API endpoints#11446
[API] Enforce pk ordering for API endpoints#11446SchrodingersGat merged 7 commits intoinventree:masterfrom
Conversation
- Append 'pk' ordering to InvenTreeOrderingFilter
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR addresses unstable ordering in paginated API list endpoints by ensuring a deterministic ordering that avoids duplicates / dropped items across pagination boundaries (ref #11442).
Changes:
- Updates the custom DRF ordering backend to enforce a stable ordering by appending a tie-breaker field.
- Replaces aliased ordering filter backend constants across multiple API modules to consistently use the custom ordering backend.
- Adds a regression test covering pagination stability for the stock list endpoint.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/backend/InvenTree/stock/test_api.py |
Adds a pagination regression test for /api/stock/ to detect duplicate PKs across pages. |
src/backend/InvenTree/stock/api.py |
Switches list endpoints to the updated ordering backend constant. |
src/backend/InvenTree/part/api.py |
Switches list endpoints to the updated ordering backend constant. |
src/backend/InvenTree/order/api.py |
Switches list endpoints to the updated ordering backend constant and simplifies imports. |
src/backend/InvenTree/company/api.py |
Switches list endpoints to the updated ordering backend constant and removes alias import. |
src/backend/InvenTree/common/api.py |
Switches list endpoints to the updated ordering backend constant and simplifies imports. |
src/backend/InvenTree/build/api.py |
Switches list endpoints to the updated ordering backend constant. |
src/backend/InvenTree/InvenTree/filters.py |
Implements stable ordering behavior in InvenTreeOrderingFilter and consolidates filter backend constants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this PR will degrade performance by 14.5%
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11446 +/- ##
=======================================
Coverage 88.02% 88.03%
=======================================
Files 1296 1296
Lines 59003 59038 +35
Branches 1938 1938
=======================================
+ Hits 51940 51974 +34
- Misses 6581 6582 +1
Partials 482 482
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
* Add unit test to detect unreliable pagination * Enforce PK field ordering - Append 'pk' ordering to InvenTreeOrderingFilter * Use our ordering filter everywhere * Simplify ordering options * Enforce list * Use last term for ordering checks * Individual delete to fix mysql issue (cherry picked from commit 3bbdddf)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
* Add unit test to detect unreliable pagination * Enforce PK field ordering - Append 'pk' ordering to InvenTreeOrderingFilter * Use our ordering filter everywhere * Simplify ordering options * Enforce list * Use last term for ordering checks * Individual delete to fix mysql issue (cherry picked from commit 3bbdddf) Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
References