Skip to content

Treat WITH TIES as a keyword phrase in Transact-SQL - #998

Closed
zzoraemon043 wants to merge 1 commit into
sql-formatter-org:masterfrom
zzoraemon043:fix/tsql-with-ties
Closed

zzoraemon043 wants to merge 1 commit into
sql-formatter-org:masterfrom
zzoraemon043:fix/tsql-with-ties

Conversation

@zzoraemon043

Copy link
Copy Markdown

Fixes #984

In SELECT TOP (n) WITH TIES ... the WITH was tokenized as the start of a CTE, so the clause was split over three lines and TIES was not upper-cased. Adding WITH TIES to the Transact-SQL keyword phrases makes the tokenizer match the two words together, so a real WITH x AS (...) CTE is unaffected.

Tests cover TOP (n) WITH TIES, TOP (n) PERCENT WITH TIES and TOP n WITH TIES without parentheses. The full test suite passes.

@nene

nene commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

I'm adopting a new policy for this repository: no AI-generated contributions. I don't care how good they are.

This is to preserve my sanity.

@nene nene closed this Oct 29, 2026
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.

[FORMATTING] T-SQL: TOP (n) WITH TIES is parsed as the start of a CTE

2 participants