Skip to content

Releases: sql-formatter-org/sql-formatter

12.0.0

11 Nov 10:42
Compare
Choose a tag to compare

Major formatting style change

Most of the simple statements are now formatted more on one line (#483).

For example the following SQL, previously formatted as follows:

ALTER TABLE
  foo
ALTER COLUMN
  col1
SET DEFAULT
  10;

DROP TABLE
  my_tbl;

DELETE FROM
  customers
WHERE
  age > 99;

UPDATE
  orders
SET
  price = 0,
  total = 0
WHERE
  deleted = TRUE;

will now be formatted on a single line:

ALTER TABLE foo
ALTER COLUMN col1
SET DEFAULT 10;

DROP TABLE my_tbl;

DELETE FROM customers
WHERE
  age > 99;

UPDATE orders
SET
  price = 0,
  total = 0
WHERE
  deleted = TRUE;

New API for smaller bundle size

When using the format() function, all the dialects need to be loaded because the actual dialect is determined at runtime. Which means a bundler like Webpack will need to bundle up code of all the dialects even when just a single one is needed. This will be something like 4x overhead compared to bundling just a single dialect.

There's now a new API which enables tree-shaking to eliminate the code of unused dialects:

import { formatDialect, sqlite } from "sql-formatter";

formatDialect("SELECT * FROM tbl", { dialect: sqlite });

See the docs for details.

Related issues/PRs: #511 #515 #452

Breaking changes in extension API

The above change also breaks the current extension API. Notably the language parameter no more works for specifying a custom dialect. Instead use the new formatDialect() API for the same purpose.

Also, instead of extending the Formatter class, there's now a DialectOptions object (#493). So one no more needs to extend a class, but can simply provide a config object.

Other new features

  • Support for custom quote types (in custom dialect config) #516 #503

Bugfixes

  • Support named function arguments in Trino with => operator #510
  • Add package.json to list of exports #499
  • Support nested CASE expressions #494
  • The MySQL USE keyword formatting should no more cause syntax error #456

12.0.0-beta.6

08 Nov 15:09
Compare
Choose a tag to compare
12.0.0-beta.6 Pre-release
Pre-release

Bugfixes

  • Fix tree-shaking when using formatDialect() and single-dialect import #517 #452

12.0.0-beta.5

05 Nov 10:01
Compare
Choose a tag to compare
12.0.0-beta.5 Pre-release
Pre-release

New features

  • Add support for custom quote types #516 #503

12.0.0-beta.4

04 Nov 17:48
Compare
Choose a tag to compare
12.0.0-beta.4 Pre-release
Pre-release

New features

New API for importing single SQL dialect to reduce bundle size #511 #515 #452

See the docs for details.

Breaking changes

This breaks the use of language option for custom dialects. Use the new dialect option instead for the same purpose.

12.0.0-beta.3

02 Nov 11:53
Compare
Choose a tag to compare
12.0.0-beta.3 Pre-release
Pre-release

Bugfixes

  • Support named function arguments in Trino with => operator #510

12.0.0-beta.2

20 Oct 13:04
Compare
Choose a tag to compare
12.0.0-beta.2 Pre-release
Pre-release

Bugfixes

  • Add package.json to list of exports #499

12.0.0-beta.1

11 Oct 16:55
Compare
Choose a tag to compare
12.0.0-beta.1 Pre-release
Pre-release

Major formatting style change

Most of the simple statements are now formatted more so on one line (#483).

For example the following SQL, previously formatted as follows:

ALTER TABLE
  foo
ALTER COLUMN
  col1
SET DEFAULT
  10;

DROP TABLE
  my_tbl;

DELETE FROM
  customers
WHERE
  age > 99;

UPDATE
  orders
SET
  price = 0,
  total = 0
WHERE
  deleted = TRUE;

will now be formatted on a single line:

ALTER TABLE foo
ALTER COLUMN col1
SET DEFAULT 10;

DROP TABLE my_tbl;

DELETE FROM customers
WHERE
  age > 99;

UPDATE orders
SET
  price = 0,
  total = 0
WHERE
  deleted = TRUE;

Breaking change in extension API

Instead of extending the Formatter class, there's now a DialectOptions object (#493).
This object can now be supplied to language parameter to implement a custom SQL dialect.

Bugfixes

  • Support nested CASE expressions (#494)
  • The MySQL USE keyword formatting should no more cause syntax error (#456)

11.0.2

05 Oct 06:50
Compare
Choose a tag to compare

Bugfixes

  • Fix indentation of first comment in file #481

11.0.1

03 Oct 13:02
Compare
Choose a tag to compare

Bugfixes

  • Fix ESM/TypeScript module resolution #487 #488 (thanks to An Phi)

11.0.0

30 Sep 07:40
Compare
Choose a tag to compare

Potentially breaking changes

  • The library is now exported as ES module #455, #105

New features

  • Added support for Snowflake dialect #454

Improvements

  • Better CASE expression formatting #458, #401, #459
  • Better formatting of inline block-comments #462
  • Better ON UPDATE/DELETE constraints formatting #478
  • denseOperators config now also applies to : operator.