Skip to content

fix: keep OUTER JOIN keywords intact in SQL formatter; document SQLite 3.39 - #5

Merged
Xof merged 1 commit into
mainfrom
fix/format-sql-outer-join
Jun 21, 2026
Merged

fix: keep OUTER JOIN keywords intact in SQL formatter; document SQLite 3.39#5
Xof merged 1 commit into
mainfrom
fix/format-sql-outer-join

Conversation

@Xof

@Xof Xof commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

P4 display & docs (closes E1, E2)

E1 — format_sql split OUTER JOIN keywords across two lines

The SQL pretty-printer broke before clauses by inserting a newline before each
keyword. The bare JOIN rule's regex (\s+(JOIN)\b) matched the space inside
the compiler-emitted LEFT/RIGHT/FULL OUTER JOIN, producing:

FROM "s" LEFT OUTER
JOIN "sp" ON ...

Reordering the keyword list does not fix it — the later bare-JOIN pass
re-splits any compound form already placed on its own line. Fix: a negative
lookbehind makes the bare-JOIN rule decline a JOIN preceded by
OUTER/INNER/LEFT/RIGHT/FULL/CROSS, leaving the dedicated multi-word rules to
break those clauses as a single unit. Natural/theta/equijoin bare JOIN still
breaks, and division's paren-counted subquery indentation is untouched.

E2 — README SQLite version caveat

RIGHT/FULL OUTER JOIN require SQLite 3.39+ (2022). Added a one-line note
to 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 keyword
contiguously on one line; bare JOIN still breaks; division subquery
indentation is preserved.

Local gate green: ruff, mypy, pytest (113 passed, 15 skipped).

…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.
@Xof
Xof merged commit de31650 into main Jun 21, 2026
5 checks passed
@Xof
Xof deleted the fix/format-sql-outer-join branch June 21, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant