fix: do not treat semicolons inside comments as statement terminators - #843
Merged
tconbeer merged 3 commits intoAug 3, 2026
Merged
Conversation
sqlfmt raised "Could not parse SQL at position N" when a comment inside
an unsupported DDL statement contained a semicolon, e.g.
create TABLE a (
A text --test; it's a comment
)
The unsupported_line rule matched greedily up to the first `;` or
newline, so it consumed the comment marker and the comment text up to
the semicolon as DATA. The remainder of the comment was then lexed as
SQL, producing a parsing or bracket error.
Stop unsupported_line at the start of a comment (--, #, //, /*) with a
lookahead, so the higher-priority comment rule lexes the whole comment
including any semicolons it contains.
Adds a parametrized regression test covering all four comment styles and
a CHANGELOG entry.
tconbeer
force-pushed
the
fix/semicolon-in-unsupported-ddl-comment
branch
from
August 3, 2026 15:23
a812eae to
e416385
Compare
Owner
|
fantastic, thank you very much! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #838
A comment inside an unsupported DDL statement was truncated at the first semicolon:
unsupported_linematched greedily up to;or a newline, consuming the comment marker and part of its text as DATA, so the rest of the comment was lexed as SQL and raised a parsing/bracket error.unsupported_linenow stops at the start of a comment (--,#,//,/*) via lookahead, letting the higher-prioritycommentrule take the whole comment. Regression test covers all four comment styles and fails onmain.