fix: keep OUTER JOIN keywords intact in SQL formatter; document SQLite 3.39 - #5
Merged
Conversation
…e 3.39 E1: format_sql's bare-JOIN line-break rule matched the space inside the compiler-emitted "LEFT/RIGHT/FULL OUTER JOIN", splitting the keyword across two lines. Reordering the keyword list does not help (the bare-JOIN pass re-splits any already-placed compound form). A negative lookbehind makes the bare-JOIN rule decline a JOIN that belongs to a compound keyword, so the dedicated multi-word rules break those clauses as one unit. Natural/theta/ equijoin bare JOIN and division subquery indentation are unchanged. E2: README now notes that RIGHT/FULL OUTER JOIN require SQLite 3.39+ (2022), in both the outer-join usage block and the backend-coverage note. Adds TestOuterJoinFormatting. Closes E1, E2.
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.
P4 display & docs (closes E1, E2)
E1 —
format_sqlsplitOUTER JOINkeywords across two linesThe SQL pretty-printer broke before clauses by inserting a newline before each
keyword. The bare
JOINrule's regex (\s+(JOIN)\b) matched the space insidethe compiler-emitted
LEFT/RIGHT/FULL OUTER JOIN, producing:Reordering the keyword list does not fix it — the later bare-
JOINpassre-splits any compound form already placed on its own line. Fix: a negative
lookbehind makes the bare-
JOINrule decline aJOINpreceded byOUTER/INNER/LEFT/RIGHT/FULL/CROSS, leaving the dedicated multi-word rules tobreak those clauses as a single unit. Natural/theta/equijoin bare
JOINstillbreaks, and division's paren-counted subquery indentation is untouched.
E2 — README SQLite version caveat
RIGHT/FULL OUTER JOINrequire SQLite 3.39+ (2022). Added a one-line noteto both the outer-join usage block and the backend-coverage callout;
how="left"works on all supported versions.Tests
TestOuterJoinFormatting: all three outer-join shapes render their keywordcontiguously on one line; bare
JOINstill breaks; division subqueryindentation is preserved.
Local gate green:
ruff,mypy,pytest(113 passed, 15 skipped).