Releases: sql-formatter-org/sql-formatter
12.0.3
12.0.2
12.0.1
12.0.0
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
Bugfixes
12.0.0-beta.6
12.0.0-beta.5
12.0.0-beta.4
12.0.0-beta.3
Bugfixes
- Support named function arguments in Trino with
=>
operator #510
12.0.0-beta.2
Bugfixes
- Add package.json to list of exports #499
12.0.0-beta.1
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.