mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-04 18:23:05 +00:00
frappe's db_query SILENTLY drops ORDER BY for distinct queries on Postgres (the ORDER BY column must appear in the SELECT-DISTINCT list), so `get_all/get_list(distinct=True, order_by="<col>")` is a no-op there and the result comes back unordered — the root cause of the Sales Register, Purchase Register and Sales Analytics ordering fixes. Add an AST rule to .github/helper/postgres_compat.py that flags this (literal order_by only; an empty order_by="" suppression and a dynamic/variable order_by are not flagged). `# pg-ok` escape hatch as usual. Grandfather the three pre-existing low-impact sites the rule surfaces (paging/iteration order only, not data): job_card operation autocomplete, inventory_dimension config list, and a work_order test loop.