Repository navigation
Add an option to stop treating blank lines as a statement separator - #2800
Merged
manticore-projects merged 4 commits intoOct 13, 2026
Conversation
Three consecutive newlines end a statement, like `;`. Add Feature.allowBlankLinesAsStatementSeparator (enabled by default) and withBlankLinesAsSeparator(boolean) so callers can parse blank lines as plain whitespace instead. Default behaviour is unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
edeadington
marked this pull request as ready for review
October 13, 2026 09:19
…line-statement-separator # Conflicts: # src/main/java/net/sf/jsqlparser/parser/AbstractJSqlParser.java # src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Smart trick, appreciated! |
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.
ST_SEMICOLONmatches"\n\n\n", so three newlines in a row end a statement, the same as;. No SQL dialect ends a statement at a blank line (the closest is SQL*Plus, which does so unlessSQLBLANKLINESis on), but generated or hand-formatted SQL often has blank lines inside a single statement, and that SQL then fails to parse at whatever comes after the gap.This has come up a few times (#1891, #1988, #2156, #2346, #2352). Those were closed because the behaviour is by design, so this PR leaves it alone. Instead it adds
Feature.allowBlankLinesAsStatementSeparator, which is enabled by default. Callers who want blank lines treated as plain whitespace can turn it off withwithBlankLinesAsSeparator(false):The
ST_SEMICOLONtoken is unchanged. When the option is off,SimpleCharStream.BeginToken()replaces the first newline of a\n\n\nrun with a space before the token manager sees it, asallowHashLineCommentsalready does. Unlike stripping blank lines before parsing, this leaves string literals alone and keeps error line numbers accurate.;,goand/still separate statements.withBlankLinesAsSeparator(false)SELECT a\n\n\nFROM tEncountered: <K_FROM>at line 4SELECT a FROM tSELECT a FROM t\n\n\nWHERE b = 1Encountered: <K_WHERE>at line 4SELECT a FROM t WHERE b = 1SELECT a FROM t WHERE b = 1\n\n\nAND c = 2Encountered: <K_AND>at line 4SELECT a FROM t WHERE b = 1 AND c = 2SELECT a FROM t\n\n\nUNION\nSELECT b FROM uEncountered: <K_UNION>at line 4SELECT a FROM t UNION SELECT b FROM uparseStatements("SELECT 1\n\n\nSELECT 2")testBlankLinesAsSeparatorDisabledcovers blank lines in each clause, trailing blank lines, a string literal containing\n\n\n, the other separators, and the reported error position.