#2740·WrenAI

strip_trailing_semicolon doesn't strip a semicolon before a trailing SQL comment

Author: AmirF194Created Sep 10, 2026Updated Sep 10, 2026

strip_trailing_semicolon in connector/base.py only strips a ; that is literally the last thing in the string (_TRAILING_SEMICOLONS_RE = re.compile(r"[;\s]+\Z")). A comment after the semicolon on the same line defeats it:

python
from wren.connector.base import strip_trailing_semicolon
strip_trailing_semicolon("SELECT 1 AS x; -- pick")
# 'SELECT 1 AS x; -- pick', unchanged

Every connector calls this before wrapping for LIMIT/dry_run, so the surviving ; lands inside the subquery:

SELECT * FROM (
SELECT 1 AS x; -- pick
) AS _sub LIMIT 0

sqlglot rejects that with ParseError: Expecting ). Line 2, Col: 13.

Distinct from #2498/#2499: those route each connector's dry_run/query calls through this same helper, but the helper has this gap no matter where it's called from, so hoisting the call to one boundary wouldn't fix it either.

Fix looks like widening the regex to also eat a trailing line comment (and whitespace) after the semicolon, plus a case in test_strip_trailing_semicolon.py. Happy to send a PR if useful.