Repository navigation
Releases
Releases · kronor-io/pgstyle
v0.1.2.0
What's Changed
- Lay out plain SQL from libpg_query's parse tree by @lorenzo in #4
- Lay out plain SQL statements with comments inside them by @lorenzo in #5
- Keep blank lines before comments and dollar-quoted strings as written by @lorenzo in #6
- Put values rows on one line each when they all fit by @lorenzo in #7
- Keep blank lines between values rows by @lorenzo in #8
- Lay out create table and create view in the syntax backend by @lorenzo in #9
- Lay out create index and alter table in the syntax backend by @lorenzo in #10
- Lay out create function in the syntax backend by @lorenzo in #11
- Lay out create trigger, grant and revoke in the syntax backend by @lorenzo in #12
- Lay out index include and with, alter constraint, keys using an index and partitions by @lorenzo in #13
- Apply sqiff's readability process: refactor round, docs and hopinion checks by @lorenzo in #14
- Write a subquery's explicit all once by @lorenzo in #15
- Readability round two: shapes, function parts, trigger and grant clauses from the tree by @lorenzo in #16
- Readability round three: name spellings, environment stages, one parenthesis walk by @lorenzo in #17
- Rename to pgstyle, Docker image on each release; pgstyle 0.1.2.0 by @lorenzo in #18
Full Changelog: v0.1.1.0...v0.1.2.0
v0.1.1.0
What's Changed
Full Changelog: v0.1.0.1...v0.1.1.0
v0.1.0.1
What's Changed
Full Changelog: v0.1.0.0...v0.1.0.1
pgfmt 0.1.0.0
The first release of pgfmt: a formatter for PostgreSQL files that does not change what any statement does.
Install
pgfmt is built with Nix for x86_64-linux, aarch64-linux and aarch64-darwin, and the binaries are in the kronor-open cache:
nix run github:kronor-io/pgfmt/v0.1.0.0 -- --help
nix profile install github:kronor-io/pgfmt/v0.1.0.0There are no prebuilt tarballs yet. To build with cabal, see Building from source: it needs libpg_query 18 with nix/libpg_query-set-values-as-strings.patch applied.
What it does
- Formats PostgreSQL files statement by statement, and rewrites a statement
only when libpg_query parses the new text to the same statement, with the
same number of comments. Text between statements is copied byte for byte. - Two backends: pgfmt's own renderer for DML, with leading commas, and
libpg_query's pretty-printer for everything PostgreSQL parses, including all
DDL.--backend auto, the default, uses the first where it can. --checkfor CI and pre-commit: names the files that are not formatted and
exits 1, changing nothing.--keyword-case lower|upper, applied to every statement in the file,
whichever backend laid it out. Identifiers are never changed.- Formats the SQL statements inside PL/pgSQL function bodies, and keeps the new
body only if it parses to the same PL/pgSQL. SETvalues keep their single quotes:set lock_timeout to '50ms'stays as
it is. libpg_query 18.0.0 writes such values as quoted identifiers
("50ms"); the flake builds it with
nix/libpg_query-set-values-as-strings.patch.--dialect hasql-thlets thesyntaxbackend read hasql-th's quasiquote
extensions, and the library exposesPgFmt.Render.formatSqlfor them.- Builds with Nix for
x86_64-linux,aarch64-linuxandaarch64-darwin;
binaries come from the kronor-open cache.
How pgfmt fits with sqiff, sqint and the other tools: sqitchcraft.