Skip to content

feat(format): lay out SQL Server table hints, table samples, table variables, FOR XML, FOR JSON, FOR SYSTEM_TIME and join hints - #59

Merged
kvlonge merged 1 commit into
mainfrom
feat/sqlserver-format-sqlquack-56c7c15e
Nov 10, 2026
Merged

kvlonge merged 1 commit into
mainfrom
feat/sqlserver-format-sqlquack-56c7c15e

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Why

SQLQuack main 56c7c15e (the analysis speed set plus native SQL Server syntax) is the rev SQLBuild's cutover pins. Its SQL Server parser now reads clauses it used to keep as opaque text, so SQLClean can lay those T-SQL queries out instead of leaving them as written.

Changes

  • Cargo.toml and Cargo.lock: all 11 sqlquack-* crates are pinned to rev = "56c7c15ecafe61ea6650159469234db670dea8da". The pin uses the full SHA, not a tag, matching SQLBuild's.
  • format now lays out T-SQL queries with:
    • TABLESAMPLE
    • WITH (...) table hints
    • table variables such as @t
    • FOR XML, FOR JSON and FOR BROWSE
    • FOR SYSTEM_TIME AS OF and ALL
    • join hints such as INNER LOOP JOIN
  • Lowercase LOOP, HASH and NOLOCK hints keep the case they were written in.
  • The T-SQL statement splitter refuses statements SQL Server rejects. FOR SYSTEM_TIME FROM/TO, BETWEEN and CONTAINED IN with column bounds stay refused, now with SQL Server's own syntax error.
  • sqlquack_departures.json: the 16 T-SQL departures for those queries are removed, because each now matches the corpus layout exactly. The reason text of the 3 FOR SYSTEM_TIME refusals is updated.
  • Corpus test: T-SQL now expects 68 formatted and 7 refused (was 52 and 23). No other test changes.

Verification

  • cargo test --all --locked: 48 passed, 0 failed. cargo fmt --check passes. uv run pytest tests: 72 passed, with the native package rebuilt from this branch.
  • Corpus dump (format at no width and at 80, query_fingerprint, lint) against v0.7.0: only 38 format tsql lines differ (16 queries now formatted at both widths, plus 3 changed refusal reasons). Everything else is byte-identical.
  • At SQLQuack 4dfb5fc9 (main just before the T-SQL merge) the dump is cmp-equal to v0.7.0's, so the speed set changes no output.

…riables, FOR XML, FOR JSON, FOR SYSTEM_TIME and join hints

Pin SQLQuack 56c7c15e. Its SQL Server parser now reads TABLESAMPLE,
WITH (...) table hints, table variables such as @t, FOR XML, FOR JSON
and FOR BROWSE, FOR SYSTEM_TIME AS OF and ALL, and join hints such as
INNER LOOP JOIN, so format lays these queries out where it left them
as written before. 16 T-SQL corpus queries now come out exactly as
the corpus records them.

FOR SYSTEM_TIME FROM ... TO, BETWEEN and CONTAINED IN with column
bounds are still refused, now with SQL Server's own syntax error.
Lowercase LOOP, HASH and NOLOCK hints keep the case they were written
in, and the T-SQL statement splitter refuses statements SQL Server
rejects.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Deploying sqlclean with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2d0b174
Status: ✅  Deploy successful!
Preview URL: https://d3258a06.sqlclean.pages.dev
Branch Preview URL: https://feat-sqlserver-format-sqlqua.sqlclean.pages.dev

View logs

@kvlonge
kvlonge merged commit b781945 into main Nov 10, 2026
15 checks passed
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