Skip to content

feat(format): add the clauseBodyStyle and isolateSemicolon options - #796

Open
edjubert wants to merge 7 commits into
supabase-community:mainfrom
edjubert:edjubert/clause-breaking
Open

edjubert wants to merge 7 commits into
supabase-community:mainfrom
edjubert:edjubert/clause-breaking

Conversation

@edjubert

@edjubert edjubert commented Sep 16, 2026

Copy link
Copy Markdown

What

Option Default Values
clauseBodyStyle "break" "break", "compact"
isolateSemicolon false boolean

clauseBodyStyle=compact

Keeps the first element of a clause body on the keyword line instead of starting a new one.
Applies to WHERE/HAVING/ON conditions and to FROM/WINDOW bodies:

-- break (default, today's output)
from
	staging.buildings
where
	staging.buildings.construction_year > 1950

-- compact
from staging.buildings
where staging.buildings.construction_year > 1950

isolateSemicolon=true

Puts the terminating semicolon on its own line, but only when the statement already spans several lines - a one-line statement keeps its ; attached:

select
	staging.buildings.id,
	staging.buildings.construction_year
from
	staging.buildings
;

Why

compact is the shape most hand-written SQL in data pipelines already uses, and it saves a line per clause on wide screens.
The isolated semicolon is what makes a multi-statement migration file diff cleanly: adding a statement at the end no longer rewrites the previous statement's last line.

Implementation

clauseBodyStyle is resolved in renderer.rs when a clause group is opened, and in select_stmt.rs / nodes/mod.rs for the clauses that emit their own break.
isolateSemicolon is a renderer decision taken once the statement is known to be multi-line.

Wiring: pgls_configuration (--clause-body-style, --isolate-semicolon), pgls_workspace settings, docs/features/formatting.md, docs/schema.json.

Tests

Three new fixtures (compact_clause_condition, compact_from_clause, isolated_semicolon) with snapshots.
Defaults leave every existing snapshot untouched.

The two preparatory commits

The first two commits of this PR are shared, byte for byte, with the three other formatter-option PRs open alongside it:

The shared commits are:

  • test(pretty-print): allow per-fixture format configuration
  • refactor(pretty-print): thread the format config into the emitter

They are carried in each PR so every option remains independently reviewable and mergeable.
Whichever PR lands first, I will rebase the other three to remove the duplicate commits.

Merge them in whatever order suits you; nothing here depends on the others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant