Skip to content

v0.2.0 — Per-block dialect via --sql@<alias> + 5 new formatter knobs

Latest

Choose a tag to compare

@andrelopes-code andrelopes-code released this 22 May 17:44
· 1 commit to main since this release

Highlights

  • --sql@<alias> for per-block dialect override. Tag a template literal with --sql@rm and the extension resolves the dialect via sqlFormatAndHighlight.databases:

    "sqlFormatAndHighlight.dialect": "transactsql",
    "sqlFormatAndHighlight.databases": {
      "rm": "transactsql",
      "pesagem": "postgresql"
    }

    Each block is formatted using its alias's dialect. Unmapped aliases fall back to the global dialect silently. The @alias token is compatible with other tools that already use --sql@db for routing — same marker, complementary purposes.

  • Five new settings covering the rest of the sql-formatter surface:

    • dataTypeCaseupper/lower/preserve for INT, VARCHAR, etc. in DDL. Fixes a regression where varchar lowercase leaked through even with keywordCase: upper.
    • useTabs — tab-indented output.
    • expressionWidth — line-wrap threshold.
    • linesBetweenQueries — blank lines between ;-separated statements.
    • newlineBeforeSemicolon — closing ; on its own line.
  • README revamped with a multi-database recipe and a stronger 'set your dialect once' opening — the generic default rejects vendor-specific syntax silently.

  • 12 new T-SQL robustness tests covering bracketed identifiers, DECLARE @var, CTE with ;WITH, MERGE, TOP (N), OUTPUT INTO, @@vars, CROSS APPLY, IDENTITY_INSERT, BEGIN TRY/CATCH, EXEC sp_executesql, and OVER (PARTITION BY). Plus 7 detector tests for @<alias> extraction and 4 for the resolver.

Compatibility

Fully backwards compatible with 0.1.0. The new @<alias> syntax is opt-in; existing markers (--sql, --sql:flag, --sql:rm:verbose) keep working exactly as before.

See CHANGELOG.md for the full detail.