Repository navigation
fix: keep converted SQL on one line where its layout cannot be checked - #128
Merged
Merged
Conversation
layout_sql, which convert, the Python API and the playground call, now returns checked_layout's result or the SQL unchanged. checked_layout first refuses text its tokenizer does not model: a $, a prefixed string such as E'', an unclosed quote, or an unclosed or nested comment. Its token comparison re-tokenizes both sides with the same tokenizer, so it cannot see a literal that tokenizer misreads.
kvlonge
added a commit
that referenced
this pull request
Nov 6, 2026
Contributor
Author
|
Pre-slot gate at bb134a2 (main d19c7a5 merged in):
Lands after the D272c slot; if main moves, it re-merges and re-gates first. |
Contributor
Author
|
Landing gate at 9ecf9fe (main df143dd merged in):
|
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.
Why
The layout's tokenizer models single-quoted strings, quoted names and
--//* */comments. It does not model DuckDB's$$/$tag$strings, prefixed strings such asE'…\'…', or nested comments. Converted SQL contains none of them today, butconvert, the Python API and the playground calledlayout_sqlunchecked. If a later rule emits one, a break or collapsed space could land inside a literal and change the SQL silently. The existing token check can't see that, because it re-tokenizes both sides with the same tokenizer.Changes
checked_layoutfirst refuses SQL holding text the layout does not model: a$, a string directly after a word (E'',X''), an unclosed quote, or an unclosed or nested comment. Then it checks, as before, that the tokens are equal ignoring whitespace and that a second layout changes nothing.layout_sql, which the CLI, Python and wasm call, now returnschecked_layout's result, or the SQL unchanged on one line when the check fails.Verification
$$string, anE''string with an escaped quote, and a nested comment. Each holds a clause word and doubled spaces in a statement long enough to break. The test asserts the refusal reason and thatlayout_sqlreturns the input unchanged.verifylays out every converted case throughchecked_layout, so no converted case falls back.make check-ci,make test-rust,make verify-recorded.