Skip to content

0.23.0

Choose a tag to compare

@nene nene released this 10 Oct 13:35
· 2 commits to master since this release

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.id

after:

SELECT *
FROM client
LEFT JOIN client_sale ON client_sale.client_id = client.id

See 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

Embedded code formatting improvements

  • Format PL/pgSQL and SQL inside a PostgreSQL DO statement. #70
  • Format SQL inside PL/pgSQL EXECUTE and BigQuery EXECUTE 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