diff --git a/.github/POSTGRES_COMPATIBILITY.md b/.github/POSTGRES_COMPATIBILITY.md index 952ea92b564..675e47d62e7 100644 --- a/.github/POSTGRES_COMPATIBILITY.md +++ b/.github/POSTGRES_COMPATIBILITY.md @@ -39,8 +39,9 @@ Flag a changed query that uses any of these: `frappe.query_builder.functions` equivalents (`CombineDatetime`, `DateDiff`, `Case`, `GroupConcat`, …) or a precomputed column (e.g. `posting_datetime`). - **`UPDATE … JOIN`** — not valid on PostgreSQL. Rewrite as `UPDATE … WHERE name IN (subquery)`. -- **`HAVING` referencing a `SELECT` alias** with no `GROUP BY` — move the predicate into `WHERE` - on the underlying expression. +- **`HAVING` referencing a `SELECT` alias** — PostgreSQL rejects output-column aliases in + `HAVING` (regardless of whether the query has a `GROUP BY`; MariaDB allows them). Repeat the + underlying expression in `HAVING`, or move a non-aggregate predicate into `WHERE`. - **`SELECT DISTINCT … ORDER BY `** — add the expr to the select. - **Single-quoted column alias** `AS 'x'` — PostgreSQL reads `'x'` as a string literal. Use an unquoted (or double-quoted) alias. diff --git a/.greptile/config.json b/.greptile/config.json index 3ba2e594b25..62a5b58e7e3 100644 --- a/.greptile/config.json +++ b/.greptile/config.json @@ -12,7 +12,10 @@ "files": [ { "scope": [ - "**/*.py" + "**/*.py", + "**/*.js", + "**/*.sql", + "**/report/**/*.json" ], "path": ".github/POSTGRES_COMPATIBILITY.md", "description": "MariaDB <-> PostgreSQL parity rules for ERPNext: query constructs that error on PostgreSQL or silently diverge across the two engines, the GROUP BY row-count trap, the false positives not to flag, and the rule that MariaDB output must not change. Apply to every changed database query in this PR."