Skip to content

Releases: sql-formatter-org/sql-formatter

12.0.3

22 Nov 09:44
Compare
Choose a tag to compare

Bugfixes

  • Add missing operators to SingleStoreDB (#531) (thanks to Tito Griné)

12.0.2

17 Nov 07:56
Compare
Choose a tag to compare

Bugfixes

  • Fix crash with complex expressions inside BETWEEN #523 #507

12.0.1

15 Nov 09:16
Compare
Choose a tag to compare

Bugfixes

  • Export ConfigError class as value, not as type (#521)

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)