Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ DESCRIPTION
--no-space-function : remove space between function call and the open
parenthesis.
--redundant-parenthesis: do not remove redundant parenthesis in DML.
--vertical-align : vertically align CREATE TABLE column definitions and
trailing comments. Disabled by default.

Examples:

Expand Down Expand Up @@ -265,6 +267,24 @@ SPECIAL FORMATTING
in some cases they must be preseved. Using this option will keep
redundant parenthesis untouched.

Option --vertical-align
Use this option to vertically align direct, single-line column
definitions inside CREATE TABLE statements. It aligns column names, data
types, column constraints such as DEFAULT, and trailing comments. For
example:

CREATE TABLE example (
id serial PRIMARY KEY, -- some comment
name varchar(100) NOT NULL, -- another comment
email varchar(100) NOT NULL, -- third comment
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -- last comment
);

Table-level constraints and multiline column definitions are preserved
but are not included in the alignment calculation. The option is disabled
by default and only applies to text output. It can also be enabled in a
configuration file with vertical-align=1.

HINTS
Configuration
If the default settings of pg_format doesn't fit all your needs you can
Expand Down
2 changes: 2 additions & 0 deletions doc/pg_format.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ wrap-comment=0
# Remove the space character between a function call and the open parenthesis that follow.
no-space-function=0

# Vertically align CREATE TABLE column definitions and trailing comments.
vertical-align=0
17 changes: 17 additions & 0 deletions doc/pg_format.pod
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ By default, pgFormatter tries to remove redundant parenthesis in DML but in
some cases they must be preseved. Using this option will keep redundant
parenthesis untouched.

=head2 Option --vertical-align

Use this option to vertically align direct, single-line column definitions
inside CREATE TABLE statements. It aligns column names, data types, column
constraints such as DEFAULT, and trailing comments. For example:

CREATE TABLE example (
id serial PRIMARY KEY, -- some comment
name varchar(100) NOT NULL, -- another comment
email varchar(100) NOT NULL, -- third comment
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP -- last comment
);

Table-level constraints and multiline column definitions are preserved but are
not included in the alignment calculation. The option is disabled by default
and only applies to text output.

=head1 HINTS

=head2 Configuration
Expand Down
Loading