feat: soft-split SQL statements at 2+ blank lines when ; is missing - #124
Open
Blankll wants to merge 3 commits into
Open
feat: soft-split SQL statements at 2+ blank lines when ; is missing#124Blankll wants to merge 3 commits into
Blankll wants to merge 3 commits into
Conversation
When statements are separated by 2+ blank lines followed by a SQL keyword (SELECT, INSERT, CREATE, etc.), automatically split them into separate statements even without a ; delimiter. This recovers gracefully from forgotten semicolons between queries.
Blankll
force-pushed
the
feat/soft-split-missing-semicolon
branch
4 times, most recently
from
July 28, 2026 14:32
eaafac4 to
8dd7e58
Compare
When statements are separated by 2+ blank lines followed by a SQL keyword, auto-split into separate statements even without ; delimiter. Also handles comment lines between blank lines, and suppresses false splits for CTE main queries (WITH ... AS (...) \n\n\n SELECT ...).
Blankll
force-pushed
the
feat/soft-split-missing-semicolon
branch
from
July 28, 2026 14:32
8dd7e58 to
e97e6aa
Compare
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.
Problem
When a user forgets a
;between two SQL statements, the entire text is sent as one query and PostgreSQL returns a syntax error like:This is a common UX friction — users often write multiple queries separated by blank lines without remembering the trailing
;.Solution
Added
splitRangesAtBlankLines()that runs as a post-processing step after the standard;-based split. For each statement range, it scans for 2+ consecutive blank lines followed by a SQL keyword. When found, the range is split at that point.Split keywords: SELECT, CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, TRUNCATE, GRANT, REVOKE, EXPLAIN, SHOW, DESCRIBE, USE, SET, CALL, EXEC/EXECUTE, BEGIN, COMMIT, ROLLBACK, DECLARE, ANALYZE, VACUUM, PRAGMA, REFRESH, COPY, WITH, MERGE, REPLACE
Safety: Requires 2+ blank lines (not 1) to avoid false positives — a single blank line within a multi-line statement won't split it.
Example
→ Still one statement (1 blank line, safe)
→ Split into 2 statements (2 blank lines + SELECT keyword)
Verification