Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: SQL
sqlpaginationcorrectnessordering
Add a deterministic tiebreaker column to paginated ORDER BY
Sorting only by a non-unique column makes pagination non-deterministic across pages; append a unique column (e.g. id) as a fallback sort key.
PR: hegnar-shareholders-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codesql
| 1 | ORDER BY entry_date DESC |
| 2 | LIMIT ? OFFSET ? |
Explanation (EN)
Objašnjenje (HR)
Good example
New codesql
| 1 | ORDER BY entry_date DESC, id DESC |
| 2 | LIMIT ? OFFSET ? |
Explanation (EN)
Objašnjenje (HR)