You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4fcdd05
Browse filesBrowse the repository at this point in the historyBrowse files
feat!: fold header descriptions and accept triple-quoted strings (#1242)
* feat: fold prose header strings and accept triple-quoted strings
Descriptions in MODEL, SCENARIO, SCHEMA, FUNCTION, HOOK and MACRO headers,
column descriptions, audit description options and Rule exception reasons
are stored as folded prose: a line break and the spaces around it are one
space, and a blank line is a paragraph break. Strings that are meaningful
as written (SQL, regexes, literals, meta values) keep their exact text.
Any header string may be written between triple quotes, where quotes need
no escaping. A backslash-escaped double quote in a prose string, a quote
that ends a string inside its text, and an unclosed or inner triple quote
fail with their line and column. MACRO header strings no longer depend on
quotes in the macro body.
* feat: lay out header descriptions canonically in sqb format
A description that fits stays one line, written as "..." or, when it
holds a double quote, as """...""". A longer one becomes an indented
""" block wrapped at the line width, and a short wrapped one is joined
onto one line. FUNCTION, HOOK, SCHEMA and MACRO descriptions are laid out
too. Layout never changes the stored text: each rewrite is checked to fold
back to the same description.
* feat: rewrite escaped description quotes with sqb format --fix
sqb format --fix rewrites a description that escapes double quotes with \"
as a """...""" string holding real quotes, reported as an applied
description-quotes fix. The rewrite is made only when the string's sole
backslashes escape quotes and the new string stores exactly that text.
When the project cannot compile until the rewrites are saved, Rule fixes
are skipped with a warning to rerun.
* docs: document header strings, folded descriptions and their layout
* test: add escaped description quote cases to the failure corpus
* fix: count description length as wrapped to the full line width
A """ block indents its lines under the field, so counting its lines
would make a description at the line limit fail description-length after
formatting. Count the description wrapped from its field to the full width,
as before, and update tests for folded descriptions.
* test: record goldens for escaped description quote cases
* test: use neutral example names and shard the description layout E2E
* style: satisfy clippy byte string lint
* refactor: satisfy structure checks for header strings and description fixes
* fix: read description quotes by one prose rule in every header
A double-quoted description takes backslashes literally, so it may end in
one; a single-quoted description reads \' and '' as a quote. MODEL and
MACRO headers and every header scanner share this rule, and only prose
descriptions reject a quote that runs straight on into more text, so other
header strings tokenize as before.
* fix: never change a SQL macro when laying out its description
The canonical description layout and the MACRO header layout now keep a
change only when the macro parses to the same definition afterwards.
* fix: skip triple-quoted header strings in AUDIT and contract scanners
The AUDIT header scanner and the MODEL contract type scanner use the
shared header string rules instead of their own quote handling.
* feat: rewrite doubled description quotes with sqb format --fix
A description that doubles its quotes as "" is rewritten as a triple-quoted
string like one that escapes them as \", and the quote error's help names
both.
* fix: apply description quote fixes only when the whole file then parses
A file whose headers, MACRO headers included, still fail once its
descriptions are rewritten is left as written, and the fix is reported as
refused.
* docs: list every folded description and the description quoting rules
* fix: measure a description's layout by its own line, not later header fields
A one-line header such as FUNCTION (description '...', arguments (...),
returns ...) kept its short description as written before; the layout
counted the fields after it and turned it into a block. Fields that follow
on the line no longer count towards whether a description fits.
* test: write reference-error header descriptions in the supported triple-quoted form
The two cases put a description with an escaped quote and an apostrophe
before a body reference error. Descriptions have no \" escape any more, so
they now hold the same text as a triple-quoted string, and still check that
the body error is located, typed and names the file.
description:"an escaped quote on one line fails at the quote",
344
+
source:"MACRO (\n description \"Matches a title (\\\"Miss\\\").\",\n arguments (value VARCHAR),\n returns VARCHAR,\n);\n@value\n",
345
+
expected_message:QUOTE_MESSAGE,
346
+
expected_location:(2,34),
347
+
},
348
+
MacroQuoteErrorTestCase{
349
+
description:"apostrophes elsewhere no longer let an escaped quote through",
350
+
source:"MACRO (\n description \"True when a name starts with a woman's title. Any case,\nwith or without a dot (\\\"MISS ANNA PARKER\\\", \\\"Mrs. C. O'Brien\\\").\",\n arguments (value VARCHAR),\n returns VARCHAR,\n);\n@value\n",
351
+
expected_message:QUOTE_MESSAGE,
352
+
expected_location:(3,25),
353
+
},
354
+
MacroQuoteErrorTestCase{
355
+
description:"a bare quote that ends the string early fails where it is",
0 commit comments