Format SQL-like input tolerantly and correct CASE, JOIN and CTE layout #2
Copy link
Copy link
Closed
Description
observed
The formatter flattens long CASE expressions, indents joined tables farther than the primary table, retains explicit INNER, and inserts gaps between CTEs. These do not match the intended style. Numeric TOP should be unparenthesized.
Ordinary formatting also refuses SQL-like text outside the admitted T-SQL slice, with an unhelpful parser number. Formatting is the primary task, not syntax validation.
change
- Expand nontrivial CASE blocks, align joined tables, omit INNER, join adjacent CTEs as
), next as (. - Preserve literal TOP style, and handle common function/boolean casing without lowercasing quoted names or literal values.
- Default to best-effort formatting. Keep the existing fail-closed behavior behind
-Strict. - Retain unfamiliar syntax and comments rather than translating dialects. If a region cannot be formatted safely, preserve it and explain why on stderr.
- Include useful parser messages and locations. Read/dependency failures remain errors.
Test the supplied aggregation, CTE/window, DDL and mixed-operator shapes, along with strict refusals, token preservation, idempotence, and the existing portable suite. No database execution or dialect-specific validity guarantee.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
align first projections in best-effort layout (refs #2)
royashbrook commentedon Sep 16, 2026
fixed the best-effort first-column alignment in 514d5d7, on PR #3. the first item gets two spaces only after a comma at that SELECT's own level proves it has multiple items. function commas and nested SELECT commas do not pad a single outer projection. comments and nested lists have regression checks.
67 structural + 15 feedback + 15 CLI checks pass on Windows, macOS and Linux. all 129 pinned public SQL inputs still produce second-pass-stable output. quoted values remain unchanged. no release or installed-copy update.
exact-head CI
royashbrook commentedon Sep 19, 2026
released in v2.28.0, merge 9fd24b7, tree-identical to tested 514d5d7. 67 structural + 15 feedback + 15 CLI checks pass; Windows/macOS/Linux CI is green at the reviewed head. local rerun passes too.
the shipped default is best-effort formatting, with -Strict for refusal. quoted names and values remain intact. CASE/JOIN/CTE/TOP fixes and fallback projection alignment are included. verified source bytes and default-path format/check calls after installation. no database execution.