mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 22:51:49 +00:00
ci(postgres): flag division by a possibly-zero divisor in the compat guard (#56363)
Adds the division-by-zero divergence class to the PG-compat review tooling: on a divisor that the data can drive to 0 (e.g. Sum(a)/Sum(b)), MariaDB returns NULL for division by zero while PostgreSQL raises `division by zero` and aborts the query. The portable fix is to wrap the divisor in NullIf(divisor, 0), which yields NULL on both engines (matching MariaDB). - .greptile/config.json: add it to the "would ERROR on PostgreSQL" list. - .github/POSTGRES_COMPATIBILITY.md: document it under §1 (hard breaks). - .github/helper/postgres_compat.py: note it in the docstring as a deliberately-not-statically-checked semantic divergence (data-dependent, like integer-division intent), so it stays a reviewer/Greptile concern. Tooling-only; no source query changes. The instance fix shipped in #56361.
This commit is contained in:
4
.github/helper/postgres_compat.py
vendored
4
.github/helper/postgres_compat.py
vendored
@@ -7,8 +7,8 @@ that static analysis can catch reliably with a low false-positive rate.
|
||||
|
||||
It deliberately does NOT try to catch the *semantic* divergences (loose GROUP BY,
|
||||
case-sensitive ==/IN, NULL ordering, ORDER BY ... LIMIT 1 tiebreakers, integer-division
|
||||
intent, savepoint discipline) — those genuinely need the test suite. Run the full suite
|
||||
on a Postgres site for those.
|
||||
intent, division by a possibly-zero divisor, savepoint discipline) — those genuinely need
|
||||
the test suite or a human/Greptile reviewer. Run the full suite on a Postgres site for those.
|
||||
|
||||
Escape hatch: put `# pg-ok` anywhere on the offending statement's line span (e.g. on a
|
||||
`SHOW INDEX` query that lives inside an `if frappe.db.db_type == "mariadb":` branch).
|
||||
|
||||
Reference in New Issue
Block a user