From 331f383777db113034a9f236e45ac070ada24d51 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 23 Jun 2026 13:24:49 +0530 Subject: [PATCH] ci(postgres): match CAST AS CHAR with nested parens in the checker The [^)]* span stopped at the first inner ')', so CAST(ABS(col) AS CHAR) slipped through. Use a non-greedy .+? with re.S; still zero production false positives (verified). Addresses review feedback. --- .github/helper/postgres_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/helper/postgres_compat.py b/.github/helper/postgres_compat.py index 969208f72ab..0a29ba6ee96 100755 --- a/.github/helper/postgres_compat.py +++ b/.github/helper/postgres_compat.py @@ -64,7 +64,7 @@ SQL_PATTERNS: list[tuple[re.Pattern, str]] = [ "SQL IF() is MySQL-only -> use CASE WHEN ... THEN ... ELSE ... END (frappe.qb.Case())"), (re.compile(r"\brlike\b", re.I), "RLIKE is MySQL-only -> frappe rewrites REGEXP->~* on Postgres but NOT RLIKE; use REGEXP / .regexp() / ~"), - (re.compile(r"\bcast\s*\([^)]*\bas\s+char\b", re.I), + (re.compile(r"\bcast\s*\(.+?\bas\s+char\b", re.I | re.S), # .+? spans nested parens, e.g. CAST(ABS(x) AS CHAR) "CAST(... AS CHAR) is character(1) on Postgres and truncates -> CAST AS VARCHAR (frappe Cast_(x, 'varchar'))"), ]