Repository navigation
0.23.0
Major formatting changes
JOINs are now placed at the same indentation level as FROM
before:
SELECT *
FROM
client
LEFT JOIN client_sale ON client_sale.client_id = client.idafter:
SELECT *
FROM client
LEFT JOIN client_sale ON client_sale.client_id = client.idSee PR #89 and discussion in #69. Thanks to @abrahamguo.
Single-column SELECT no longer uses a hanging indent
This mainly effects longer function calls, which previously were formatted like so:
SELECT
my_function_call(
long_argument_1,
long_argument_2,
long_argument_3
);Now it formats like so:
SELECT my_function_call(
long_argument_1,
long_argument_2,
long_argument_3
);See #86 and #75. Thanks to @joelmukuthu.
Long binary expressions break after the operator
Before:
SELECT *
FROM my_table
WHERE
description = "a table that expires in 2025, with each partition living for 24 hours";After:
SELECT *
FROM my_table
WHERE
description =
"a table that expires in 2025, with each partition living for 24 hours";See #80 and c9069a4. Thanks to @joelmukuthu.
Improved WHEN/THEN/ELSE formatting
Before:
SELECT
CASE
WHEN condition1
AND condition2 THEN 'recently active customer'
WHEN condition3 THEN 'active customer'
ELSE 'unknown customer status'
END AS customer_status
FROM customers;After:
SELECT CASE
WHEN condition1 AND condition2 THEN
'recently active customer'
WHEN condition3 THEN 'active customer'
ELSE 'unknown customer status'
END AS customer_status
FROM customers;See #78. Thanks to @joelmukuthu.
Spacing around JSON-operators
PostgreSQL -> and ->> operators no longer have spaces around them, so instead of:
SELECT col ->> 'field';one now gets:
SELECT col->>'field';See #68.
Moderate formatting changes
- Improved
CREATE INDEXformatting. #80. Thanks to @joelmukuthu. b1a2322 - Improved
COMMENT ONformatting. #76. Thanks to @joelmukuthu. - Empty parentheses after function name (e.g.
my_func()) no longer get a line break. #74. Thanks to @joelmukuthu.
Embedded code formatting improvements
- Format PL/pgSQL and SQL inside a PostgreSQL
DOstatement. #70 - Format SQL inside PL/pgSQL
EXECUTEand BigQueryEXECUTE IMMEDIATE. #82 (Thanks to @arnodirlam) - Strings in the LANGUAGE clause (e.g.
LANGUAGE 'plpgsql') are now recognized. 582dc6e, fc419e1
Fixes
- Parentheses in
count(DISTINCT (foo, bar))are kept. #73
Parser
- Upgraded sql-parser-cst to 0.42.2