From 3e2d61262a276f60fb2aba8814d9aecc6ed97670 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 22 Jun 2026 09:34:23 +0530 Subject: [PATCH] ci(greptile): widen guide scope to SQL-bearing non-Python files; fix HAVING-alias wording Address Greptile review: - customContext.files scope was **/*.py only, so Query Report SQL in .js/.sql/report .json files didn't get the guide attached as context (the global instructions still applied). Widen to .py/.js/.sql/report **/*.json. - The guide's HAVING-alias rule said "with no GROUP BY"; PostgreSQL rejects a SELECT-alias in HAVING regardless of GROUP BY. Reworded to match (repeat the expression, or move a non-aggregate predicate to WHERE). --- .github/POSTGRES_COMPATIBILITY.md | 5 +++-- .greptile/config.json | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) 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."