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
sqlsortingcorrectnesscurrency
Keep ORDER BY sort keys in the same unit/currency as the displayed value
A pagination sort key and the displayed value must use the same scale; mixing converted and raw-fallback branches reorders rows wrongly.
PR: vinify-backend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codesql
| 1 | ORDER BY COALESCE(value_in_nok * rate, raw_price) -- mixed units |
Explanation (EN)
Objašnjenje (HR)
Good example
New codesql
| 1 | ORDER BY COALESCE(value_in_nok * rate, raw_price * base_rate) -- same unit |
Explanation (EN)
Objašnjenje (HR)