diff --git a/.changeset/brisk-clauses-return.md b/.changeset/brisk-clauses-return.md deleted file mode 100644 index 4bf2bffc..00000000 --- a/.changeset/brisk-clauses-return.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -"prettier-plugin-postgresql": minor ---- - -PostgreSQL: more clauses that were silently dropped are now kept. - -- Queries: `ORDER BY … NULLS FIRST/LAST` and `USING <`, `GROUP BY DISTINCT`, - `LIKE` / `SIMILAR TO … ESCAPE`, `WITHIN GROUP (ORDER BY …)`, window - `EXCLUDE …` and base windows (`w2 AS (w …)`), `NATURAL LEFT/FULL JOIN` - (printed as an inner join), `JOIN … USING (…) AS j`, aliases on - parenthesized joins, and the parentheses around nested joins. -- Views: `OR REPLACE`, `TEMPORARY`, column lists, `WITH (…)` and - `WITH CHECK OPTION`. -- Indexes: `NULLS FIRST/LAST`, operator classes, `COLLATE`, `NULLS NOT DISTINCT`, - `WITH (…)`, `TABLESPACE`, `ON ONLY`, and parentheses around expression columns. -- Column `COLLATE`; sequence `AS`, `OWNED BY`, `TEMPORARY` and 64-bit bounds; - `DROP INDEX CONCURRENTLY`; CTE `[NOT] MATERIALIZED`. -- `EXPLAIN (analyze, …)` no longer crashes, and `COPY … csv header` no longer - prints `header ''`. diff --git a/.changeset/calm-brackets-keep.md b/.changeset/calm-brackets-keep.md deleted file mode 100644 index 411adfb5..00000000 --- a/.changeset/calm-brackets-keep.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -"prettier-plugin-tsql": minor -"prettier-plugin-postgresql": minor ---- - -T-SQL: formatting no longer changes what SQL does. - -- Bracketed reserved words keep their brackets (`[order]`, `ON [primary]`), and - bracketed index, constraint, cursor, window and other names are preserved. -- CLR and xml methods (`h.GetAncestor()`, `x.value()`) and user functions keep - their casing; only built-in functions follow `sqlKeywordCase`. -- `$action` and other pseudo-columns, `GROUP BY ALL`, `WITH ROLLUP`, - `INSERT TOP (n)`, and `EXEC … WITH RECOMPILE` are kept. -- `SET NOCOUNT, XACT_ABORT ON` no longer prints `XACTABORT`. -- `ALTER TABLE … DROP CONSTRAINT x, COLUMN y` keeps each keyword, so `y` is no - longer dropped as a constraint. -- `OUTPUT` is placed before `FROM` in `UPDATE` and multi-table `DELETE`; - `SET @v = col = expr` and `SET col.WRITE(…)` print valid SQL. -- `@variables` in hints (`OPTIMIZE FOR (@p = 1)`) keep their case. -- Compact density no longer deletes comments between WHERE predicates. - -Both plugins can now be loaded in the same process (for example a Prettier config -listing both); previously whichever parsed second failed. diff --git a/.changeset/quiet-parens-return.md b/.changeset/quiet-parens-return.md deleted file mode 100644 index 6857faa2..00000000 --- a/.changeset/quiet-parens-return.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -"prettier-plugin-postgresql": minor -"prettier-plugin-tsql": minor ---- - -PostgreSQL: formatting no longer changes what a query means. - -- Parentheses are kept wherever operator precedence needs them. Previously every - parenthesis was dropped, so `(a + b) * c` became `a + b * c` and - `(x or y) and z` became `x or y and z`. -- Double-quoted identifiers keep their quotes. Previously `"My Table"` printed as - `My Table` (invalid SQL) and `"MixedCase"(1)` as `mixedcase(1)` (a different - function). Names are now quoted exactly when PostgreSQL requires it. -- `IS TRUE` / `IS NOT FALSE` / `IS UNKNOWN` no longer print as `is istrue` etc. - -T-SQL: `sqlKeywordCase` no longer recases the inside of double-quoted names. diff --git a/.changeset/sharp-policies-hold.md b/.changeset/sharp-policies-hold.md deleted file mode 100644 index 7e7976f0..00000000 --- a/.changeset/sharp-policies-hold.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -"prettier-plugin-postgresql": minor -"prettier-plugin-tsql": minor ---- - -PostgreSQL: more fixes for formatting that changed what SQL does. - -- `CREATE POLICY … AS RESTRICTIVE` and the `TO role, …` list of `CREATE POLICY` / - `ALTER POLICY` were dropped, turning restrictive policies permissive and - role-scoped policies into policies for everyone. -- `ALTER TABLE IF EXISTS`, `DROP CONSTRAINT IF EXISTS`, and `CASCADE` on dropped - columns and constraints were dropped; `ADD COLUMN IF NOT EXISTS` printed as the - invalid `ADD COLUMN IF EXISTS`. -- `ONLY` was dropped from `SELECT`, `UPDATE`, `DELETE`, `ALTER TABLE`, `TRUNCATE` - and `LOCK`, so statements recursed into inheritance children and partitions. -- `ALTER VIEW` / `ALTER INDEX` / `ALTER MATERIALIZED VIEW` printed as `ALTER TABLE`, - and `ALTER TABLE s.t SET SCHEMA x` lost the table name. -- Unsupported `ALTER TABLE` subcommands (e.g. `OWNER TO`) now fail with a clear - error instead of printing invalid SQL such as `changeowner`. -- `SET` values: numbers were dropped (`set statement_timeout = ;`) and quoted - mixed-case values were lowercased (`search_path` `"MySchema"` → `myschema`). -- Role passwords were recased by `sqlKeywordCase` and weren't escaped. - -Both plugins: `sqlKeywordCase` never recases the inside of single-quoted literals. diff --git a/.changeset/stout-grants-stay.md b/.changeset/stout-grants-stay.md deleted file mode 100644 index fda6a600..00000000 --- a/.changeset/stout-grants-stay.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -"prettier-plugin-postgresql": minor ---- - -PostgreSQL: DDL formatting no longer drops clauses that change what a statement does. - -- `CREATE TEMP` / `UNLOGGED TABLE`, `ON COMMIT`, `IF NOT EXISTS`, `INHERITS`, - `USING`, `WITH (…)` and `TABLESPACE` are kept; `CREATE TABLE … AS` and - materialized views also keep their column lists and `WITH NO DATA`. -- `GRANT` / `REVOKE` keep column lists (`INSERT (a)`), `GRANT OPTION FOR` and - `GRANTED BY`; `CURRENT_USER` and similar grantees no longer print as nothing. -- `CREATE FUNCTION` keeps `OR REPLACE`, `SETOF`, parameter defaults and every - attribute (`SECURITY DEFINER`, `STRICT`, volatility, `PARALLEL`, `COST`, `SET`, - …); `CREATE PROCEDURE` no longer prints as `CREATE FUNCTION`; C functions keep - their link symbol; bodies containing `$$` get a safe dollar-quote tag. -- `ALTER FUNCTION … SECURITY DEFINER` no longer prints as `SECURITY INVOKER`. -- `CREATE TRIGGER` keeps `UPDATE OF` columns, function arguments, `OR REPLACE`, - constraint-trigger options and `REFERENCING` transition tables. -- Functions and `VALUES` lists in `FROM` format again, and alias column lists - (`AS g(n)`, `WITH c(a, b)`) are kept. -- `DROP`, `ALTER`, `COMMENT ON` and `GRANT` keep function and operator argument - types. diff --git a/.changeset/tidy-endings-match.md b/.changeset/tidy-endings-match.md deleted file mode 100644 index eca4b82b..00000000 --- a/.changeset/tidy-endings-match.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -"prettier-plugin-tsql": minor -"prettier-plugin-postgresql": minor ---- - -- `sqlKeywordCase: "preserve"` now follows the input: an upper-case file keeps - upper-case keywords and anything else is lower case. It previously behaved like - `"upper"`. -- T-SQL output now ends with a newline, like PostgreSQL output and Prettier's own - printers. diff --git a/packages/plugin-pgsql/CHANGELOG.md b/packages/plugin-pgsql/CHANGELOG.md index 67bf2706..84c953dc 100644 --- a/packages/plugin-pgsql/CHANGELOG.md +++ b/packages/plugin-pgsql/CHANGELOG.md @@ -1,5 +1,101 @@ # prettier-plugin-postgresql +## 0.3.0 + +### Minor Changes + +- b10a4ef: PostgreSQL: more clauses that were silently dropped are now kept. + + - Queries: `ORDER BY … NULLS FIRST/LAST` and `USING <`, `GROUP BY DISTINCT`, + `LIKE` / `SIMILAR TO … ESCAPE`, `WITHIN GROUP (ORDER BY …)`, window + `EXCLUDE …` and base windows (`w2 AS (w …)`), `NATURAL LEFT/FULL JOIN` + (printed as an inner join), `JOIN … USING (…) AS j`, aliases on + parenthesized joins, and the parentheses around nested joins. + - Views: `OR REPLACE`, `TEMPORARY`, column lists, `WITH (…)` and + `WITH CHECK OPTION`. + - Indexes: `NULLS FIRST/LAST`, operator classes, `COLLATE`, `NULLS NOT DISTINCT`, + `WITH (…)`, `TABLESPACE`, `ON ONLY`, and parentheses around expression columns. + - Column `COLLATE`; sequence `AS`, `OWNED BY`, `TEMPORARY` and 64-bit bounds; + `DROP INDEX CONCURRENTLY`; CTE `[NOT] MATERIALIZED`. + - `EXPLAIN (analyze, …)` no longer crashes, and `COPY … csv header` no longer + prints `header ''`. + +- 75e4e70: T-SQL: formatting no longer changes what SQL does. + + - Bracketed reserved words keep their brackets (`[order]`, `ON [primary]`), and + bracketed index, constraint, cursor, window and other names are preserved. + - CLR and xml methods (`h.GetAncestor()`, `x.value()`) and user functions keep + their casing; only built-in functions follow `sqlKeywordCase`. + - `$action` and other pseudo-columns, `GROUP BY ALL`, `WITH ROLLUP`, + `INSERT TOP (n)`, and `EXEC … WITH RECOMPILE` are kept. + - `SET NOCOUNT, XACT_ABORT ON` no longer prints `XACTABORT`. + - `ALTER TABLE … DROP CONSTRAINT x, COLUMN y` keeps each keyword, so `y` is no + longer dropped as a constraint. + - `OUTPUT` is placed before `FROM` in `UPDATE` and multi-table `DELETE`; + `SET @v = col = expr` and `SET col.WRITE(…)` print valid SQL. + - `@variables` in hints (`OPTIMIZE FOR (@p = 1)`) keep their case. + - Compact density no longer deletes comments between WHERE predicates. + + Both plugins can now be loaded in the same process (for example a Prettier config + listing both); previously whichever parsed second failed. + +- 2b0cc80: PostgreSQL: formatting no longer changes what a query means. + + - Parentheses are kept wherever operator precedence needs them. Previously every + parenthesis was dropped, so `(a + b) * c` became `a + b * c` and + `(x or y) and z` became `x or y and z`. + - Double-quoted identifiers keep their quotes. Previously `"My Table"` printed as + `My Table` (invalid SQL) and `"MixedCase"(1)` as `mixedcase(1)` (a different + function). Names are now quoted exactly when PostgreSQL requires it. + - `IS TRUE` / `IS NOT FALSE` / `IS UNKNOWN` no longer print as `is istrue` etc. + + T-SQL: `sqlKeywordCase` no longer recases the inside of double-quoted names. + +- 8a001d9: PostgreSQL: more fixes for formatting that changed what SQL does. + + - `CREATE POLICY … AS RESTRICTIVE` and the `TO role, …` list of `CREATE POLICY` / + `ALTER POLICY` were dropped, turning restrictive policies permissive and + role-scoped policies into policies for everyone. + - `ALTER TABLE IF EXISTS`, `DROP CONSTRAINT IF EXISTS`, and `CASCADE` on dropped + columns and constraints were dropped; `ADD COLUMN IF NOT EXISTS` printed as the + invalid `ADD COLUMN IF EXISTS`. + - `ONLY` was dropped from `SELECT`, `UPDATE`, `DELETE`, `ALTER TABLE`, `TRUNCATE` + and `LOCK`, so statements recursed into inheritance children and partitions. + - `ALTER VIEW` / `ALTER INDEX` / `ALTER MATERIALIZED VIEW` printed as `ALTER TABLE`, + and `ALTER TABLE s.t SET SCHEMA x` lost the table name. + - Unsupported `ALTER TABLE` subcommands (e.g. `OWNER TO`) now fail with a clear + error instead of printing invalid SQL such as `changeowner`. + - `SET` values: numbers were dropped (`set statement_timeout = ;`) and quoted + mixed-case values were lowercased (`search_path` `"MySchema"` → `myschema`). + - Role passwords were recased by `sqlKeywordCase` and weren't escaped. + + Both plugins: `sqlKeywordCase` never recases the inside of single-quoted literals. + +- d9fd592: PostgreSQL: DDL formatting no longer drops clauses that change what a statement does. + + - `CREATE TEMP` / `UNLOGGED TABLE`, `ON COMMIT`, `IF NOT EXISTS`, `INHERITS`, + `USING`, `WITH (…)` and `TABLESPACE` are kept; `CREATE TABLE … AS` and + materialized views also keep their column lists and `WITH NO DATA`. + - `GRANT` / `REVOKE` keep column lists (`INSERT (a)`), `GRANT OPTION FOR` and + `GRANTED BY`; `CURRENT_USER` and similar grantees no longer print as nothing. + - `CREATE FUNCTION` keeps `OR REPLACE`, `SETOF`, parameter defaults and every + attribute (`SECURITY DEFINER`, `STRICT`, volatility, `PARALLEL`, `COST`, `SET`, + …); `CREATE PROCEDURE` no longer prints as `CREATE FUNCTION`; C functions keep + their link symbol; bodies containing `$$` get a safe dollar-quote tag. + - `ALTER FUNCTION … SECURITY DEFINER` no longer prints as `SECURITY INVOKER`. + - `CREATE TRIGGER` keeps `UPDATE OF` columns, function arguments, `OR REPLACE`, + constraint-trigger options and `REFERENCING` transition tables. + - Functions and `VALUES` lists in `FROM` format again, and alias column lists + (`AS g(n)`, `WITH c(a, b)`) are kept. + - `DROP`, `ALTER`, `COMMENT ON` and `GRANT` keep function and operator argument + types. + +- 08b14d5: - `sqlKeywordCase: "preserve"` now follows the input: an upper-case file keeps + upper-case keywords and anything else is lower case. It previously behaved like + `"upper"`. + - T-SQL output now ends with a newline, like PostgreSQL output and Prettier's own + printers. + ## 0.2.9 ### Patch Changes diff --git a/packages/plugin-pgsql/package.json b/packages/plugin-pgsql/package.json index 93b752a3..56d5258b 100644 --- a/packages/plugin-pgsql/package.json +++ b/packages/plugin-pgsql/package.json @@ -1,6 +1,6 @@ { "name": "prettier-plugin-postgresql", - "version": "0.2.9", + "version": "0.3.0", "description": "Prettier plugin for PostgreSQL using the official libpg_query parser", "author": "Mike Schall", "license": "MIT", diff --git a/packages/plugin-tsql/CHANGELOG.md b/packages/plugin-tsql/CHANGELOG.md index b1a17241..b589a53b 100644 --- a/packages/plugin-tsql/CHANGELOG.md +++ b/packages/plugin-tsql/CHANGELOG.md @@ -1,5 +1,66 @@ # prettier-plugin-tsql +## 0.9.0 + +### Minor Changes + +- 75e4e70: T-SQL: formatting no longer changes what SQL does. + + - Bracketed reserved words keep their brackets (`[order]`, `ON [primary]`), and + bracketed index, constraint, cursor, window and other names are preserved. + - CLR and xml methods (`h.GetAncestor()`, `x.value()`) and user functions keep + their casing; only built-in functions follow `sqlKeywordCase`. + - `$action` and other pseudo-columns, `GROUP BY ALL`, `WITH ROLLUP`, + `INSERT TOP (n)`, and `EXEC … WITH RECOMPILE` are kept. + - `SET NOCOUNT, XACT_ABORT ON` no longer prints `XACTABORT`. + - `ALTER TABLE … DROP CONSTRAINT x, COLUMN y` keeps each keyword, so `y` is no + longer dropped as a constraint. + - `OUTPUT` is placed before `FROM` in `UPDATE` and multi-table `DELETE`; + `SET @v = col = expr` and `SET col.WRITE(…)` print valid SQL. + - `@variables` in hints (`OPTIMIZE FOR (@p = 1)`) keep their case. + - Compact density no longer deletes comments between WHERE predicates. + + Both plugins can now be loaded in the same process (for example a Prettier config + listing both); previously whichever parsed second failed. + +- 2b0cc80: PostgreSQL: formatting no longer changes what a query means. + + - Parentheses are kept wherever operator precedence needs them. Previously every + parenthesis was dropped, so `(a + b) * c` became `a + b * c` and + `(x or y) and z` became `x or y and z`. + - Double-quoted identifiers keep their quotes. Previously `"My Table"` printed as + `My Table` (invalid SQL) and `"MixedCase"(1)` as `mixedcase(1)` (a different + function). Names are now quoted exactly when PostgreSQL requires it. + - `IS TRUE` / `IS NOT FALSE` / `IS UNKNOWN` no longer print as `is istrue` etc. + + T-SQL: `sqlKeywordCase` no longer recases the inside of double-quoted names. + +- 8a001d9: PostgreSQL: more fixes for formatting that changed what SQL does. + + - `CREATE POLICY … AS RESTRICTIVE` and the `TO role, …` list of `CREATE POLICY` / + `ALTER POLICY` were dropped, turning restrictive policies permissive and + role-scoped policies into policies for everyone. + - `ALTER TABLE IF EXISTS`, `DROP CONSTRAINT IF EXISTS`, and `CASCADE` on dropped + columns and constraints were dropped; `ADD COLUMN IF NOT EXISTS` printed as the + invalid `ADD COLUMN IF EXISTS`. + - `ONLY` was dropped from `SELECT`, `UPDATE`, `DELETE`, `ALTER TABLE`, `TRUNCATE` + and `LOCK`, so statements recursed into inheritance children and partitions. + - `ALTER VIEW` / `ALTER INDEX` / `ALTER MATERIALIZED VIEW` printed as `ALTER TABLE`, + and `ALTER TABLE s.t SET SCHEMA x` lost the table name. + - Unsupported `ALTER TABLE` subcommands (e.g. `OWNER TO`) now fail with a clear + error instead of printing invalid SQL such as `changeowner`. + - `SET` values: numbers were dropped (`set statement_timeout = ;`) and quoted + mixed-case values were lowercased (`search_path` `"MySchema"` → `myschema`). + - Role passwords were recased by `sqlKeywordCase` and weren't escaped. + + Both plugins: `sqlKeywordCase` never recases the inside of single-quoted literals. + +- 08b14d5: - `sqlKeywordCase: "preserve"` now follows the input: an upper-case file keeps + upper-case keywords and anything else is lower case. It previously behaved like + `"upper"`. + - T-SQL output now ends with a newline, like PostgreSQL output and Prettier's own + printers. + ## 0.8.1 ### Patch Changes diff --git a/packages/plugin-tsql/package.json b/packages/plugin-tsql/package.json index dc85c319..b8e0c285 100644 --- a/packages/plugin-tsql/package.json +++ b/packages/plugin-tsql/package.json @@ -1,6 +1,6 @@ { "name": "prettier-plugin-tsql", - "version": "0.8.1", + "version": "0.9.0", "description": "Prettier plugin for T-SQL (Microsoft SQL Server) using the official ScriptDom parser", "author": "Mike Schall", "license": "MIT",