Conversation
This was referenced Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two new formatter options, both defaulting to the current behaviour:
commaStyle"trailing""trailing","leading"logicalOperatorPlacement"trailing""trailing","leading"They control where the separator sits when a list or a condition breaks across lines.
A list that fits on one line is unaffected.
commaStyle=leadinglogicalOperatorPlacement=leadingwith
trailing(today's output, unchanged) the same condition ends each line withand.Why
Leading commas are a long-standing convention in analytics/ETL SQL: a line can be commented out or reordered without touching its neighbours, and a missing or extra comma is visible in a diff.
The same argument applies to
AND/ORin longWHEREclauses.Both are pure style preferences, hence options rather than a change of default.
Implementation
The separator is chosen at emission time, not at render time:
node_list.rsemits the comma before or after the line break depending oncommaStyle, andbool_expr.rsdoes the same for the boolean operator.That is why the emitter needs access to the configuration (see the prerequisite PR).
Wiring:
pgls_configuration(serde +bpafCLI flags--comma-style/--logical-operator-placement),pgls_workspacesettings,docs/features/formatting.md, anddocs/schema.json.Tests
Two new fixtures with snapshots at width 80, plus the full existing snapshot suite unchanged (the defaults preserve today's output).
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:
clauseBodyStyle/isolateSemicolonlayoutcastStyleThe shared commits are:
test(pretty-print): allow per-fixture format configurationrefactor(pretty-print): thread the format config into the emitterThey 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.