Skip to content
Merged
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
4 changes: 4 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ publish-dry:
publish:
cargo publish

# Regenerate Style::PgDump fixtures from a throwaway PostgreSQL cluster
gen-pgdump-fixtures:
bash tests/fixtures/pg_dump/generate.sh

# Clean build artifacts
clean:
cargo clean
23 changes: 22 additions & 1 deletion src/formatter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod expr;
mod pgdump;
mod plpgsql;
mod select;
mod stmt;
Expand Down Expand Up @@ -138,6 +139,22 @@ impl StyleConfig {
strip_inner_join: true,
wrap_case_else: true,
},
// PgDump uses a dedicated renderer (see formatter::pgdump); these
// values are placeholders and are not consulted on that path.
Style::PgDump => Self {
upper_keywords: true,
indent: " ",
leading_commas: false,
joins_in_river: false,
explicit_inner_join: false,
blank_lines_between_clauses: false,
river: false,
compact_ctes: false,
join_on_same_line: false,
blank_lines_in_ctes: false,
strip_inner_join: false,
wrap_case_else: false,
},
}
}
}
Expand Down Expand Up @@ -166,7 +183,11 @@ impl<'a> Formatter<'a> {
if child.kind() == "toplevel_stmt"
&& let Some(stmt) = child.find_child("stmt")
{
results.push(self.format_stmt(stmt)?);
if self.style == Style::PgDump {
results.push(self.format_pgdump_stmt(stmt)?);
} else {
results.push(self.format_stmt(stmt)?);
}
}
}
if results.is_empty() {
Expand Down
Loading