Skip to content

Releases: gmr/libpgfmt

v1.2.0

15 Jun 22:22
@gmr gmr
0ee0ed8

Choose a tag to compare

pg_dump style

Adds a new Style::PgDump (pg_dump / pgdump / postgres) that reproduces PostgreSQL's ruleutils.c deparser layout — the output of pg_get_viewdef / pg_get_functiondef. Its correctness bar is byte-idempotency: formatting genuine deparser output returns it unchanged, making it suitable for canonicalizing and diffing catalog-dumped DDL.

Covers views (target lists, all JOIN forms, WHERE/GROUP BY/HAVING/ORDER BY, LIMIT/OFFSET, set operations, CTEs, multi-line CASE, comma-separated FROM, subqueries in expressions / derived tables, DISTINCT ON, FILTER, window frames, LATERAL) and functions (RETURNS scalar/SETOF/TABLE, DEFAULT/OUT/VARIADIC args, grouped behavior attributes, SET, verbatim and SQL-standard RETURN bodies).

Validated by 31 byte-idempotency fixtures captured from genuine deparser output (#13).

v1.1.7

15 Jun 19:22
@gmr gmr
fd4f05b

Choose a tag to compare

What's Changed

Changed

  • Bump tree-sitter-postgres to 1.2.4, bringing the released AT TIME ZONE and E'...' escape-string grammar fixes. Catalog-dumped views (pg_get_viewdef output) and LANGUAGE sql function bodies now parse and format without errors.

Fixed (from this release line)

  • Multi-word type names in :: casts are no longer truncated ('x'::character varying, ::bit varying(n), etc.). (#10)
  • format_plpgsql falls back to SQL formatting for non-PL/pgSQL bodies (e.g. LANGUAGE sql functions) instead of erroring. (#11)

v1.1.6

15 Jun 17:03
@gmr gmr
11fa38d

Choose a tag to compare

What's Changed

Fixed

  • Format PL/pgSQL constructs that previously rendered incorrectly: ALIAS FOR declarations (the target was dropped), RETURN NEXT / RETURN QUERY (the keyword was dropped), and FOR loops over a query (the query text after IN was dropped). (#9)

Changed

  • Bump tree-sitter-postgres to 1.2.3, which adds PL/pgSQL grammar support for multi-word type names (character varying, double precision, timestamp with time zone), DEFAULT initializers, bare RETURN NEXT, and ALIAS FOR $N. (gmr/tree-sitter-postgres#42)

v1.1.5

15 Jun 16:02
@gmr gmr
1d1ca7d

Choose a tag to compare

What's Changed

Fixed

  • Fix an infinite-loop hang when formatting PL/pgSQL bodies containing an IF … END IF statement. format_stmt_if never advanced past the closing IF of END IF, so any format_plpgsql input with an IF statement hung. (#8)
  • Fix corrupted output for decimal literals such as 0.00 and 0.0 (e.g. (0.00)::real(0 .00)::real, 0.0.0) by upgrading the grammar. (#8)

Changed

  • Bump tree-sitter-postgres to 1.2.2, which fixes a float_literal lexer bug that split decimals like 0.00 into separate tokens. (gmr/tree-sitter-postgres#41)

v1.1.4

12 Jun 16:45
@gmr gmr
3b077c0

Choose a tag to compare

What's Changed

Fixed

  • Preserve typed string literals in constant expressions. INTERVAL '2 days', DATE '...', TIMESTAMP '...', INTERVAL '2' DAY, and INTERVAL(6) '...' previously lost everything after the type keyword (gmr/pgfmt#7)

v1.1.3

12 Jun 16:03
@gmr gmr
f39f3cf

Choose a tag to compare

What's Changed

Fixed

  • Emit the comma between CTEs in non-compact WITH formatting (#7)

v1.1.2

12 Jun 15:30
@gmr gmr
57ff8d6

Choose a tag to compare

What's Changed

Changed

  • Update tree-sitter-postgres dependency from 1.0 to 1.2.1

v1.1.1

17 Apr 22:30
@gmr gmr
7af73d3

Choose a tag to compare

What's Changed

Fixed

  • Preserve column-level OPTIONS (...) clauses in CREATE FOREIGN TABLE that were previously silently dropped (#5) (#6)

v1.1.0

30 Mar 15:51
@gmr gmr
4f8d8d1

Choose a tag to compare

What's Changed

Breaking

  • Default style changed from river to AWeber

Fixed

  • All 7 previously-failing fixture tests now pass — removed KNOWN_FAILING mechanism
  • Typecast :: operator no longer adds spaces ('x' :: TEXT'x'::TEXT)
  • ARRAY[...] expressions formatted correctly
  • CAST(expr AS type) converted to PostgreSQL expr::type notation
  • COALESCE, GREATEST, LEAST formatted as FUNC(args) not FUNC ( args )
  • RANK() OVER (...) window functions: OVER clause no longer dropped
  • ANY/ALL/SOME get space before opening paren
  • VALUE pseudo-variable lowercased in domain CHECK constraints
  • Redundant parentheses stripped around simple expressions in typecasts
  • NUMERIC type keyword recognized for proper casing
  • Bare table aliases always get explicit AS keyword
  • TIMESTAMP WITH TIME ZONE / WITHOUT TIME ZONE types formatted correctly
  • CREATE FUNCTION dollar-quoting: AS $$ on same line, body indented, $$ on own line
  • CREATE TABLE WITH no longer duplicates WITH keyword
  • CREATE TABLE column constraints (DEFAULT, NOT NULL) no longer lost on nested ColQualList
  • CREATE VIEW ... AS trailing space removed
  • SELECT DISTINCT / DISTINCT ON separated from SELECT keyword for proper river alignment
  • CTE bodies inherit parent river width for consistent alignment
  • Nested WITH clauses river-aligned inside CTE bodies
  • Decimal literal fragments merged when split by tree-sitter ERROR nodes

Added

  • CREATE FOREIGN TABLE formatting with column alignment, SERVER, and OPTIONS blocks
  • wrap_case_else style config: AWeber/mattmc3 wrap CASE+ELSE, others keep inline
  • Style guide links in README for all 7 styles
  • dump_tree and format_test development examples

Full Changelog: v1.0.1...v1.1.0

v1.0.1

30 Mar 13:55
@gmr gmr
43eb74d

Choose a tag to compare

Changes

  • Preserve user-supplied grouping parentheses in boolean expressions (#3)
  • Update tree-sitter-postgres dependency to 1.0.0
  • Build fixture test styles from Style::ALL instead of hardcoding
  • Switch release workflow to crates.io trusted publishing