Skip to content

fix(pretty-print): indent broken COALESCE and GREATEST arguments - #840

Merged
psteinroe merged 1 commit into
supabase-community:mainfrom
edjubert:edjubert/coalesce-argument-indent
Oct 8, 2026
Merged

psteinroe merged 1 commit into
supabase-community:mainfrom
edjubert:edjubert/coalesce-argument-indent

Conversation

@edjubert

@edjubert edjubert commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Problem

COALESCE and GREATEST/LEAST are rendered by the CoalesceExpr and MinMaxExpr nodes, which emit their argument list without the soft break after the opening parenthesis and without the indent region that emit_standard_function wraps around the arguments of a regular function call.

When the group breaks, the only remaining break opportunity is the one before a leading comma, so wrapped arguments land at the same indentation as the line that opens the call:

ON source_payment_types.value_en =
		COALESCE(rent_issuance_parameters_payment_types.value
		, translating.leases.rent_issuance_parameters_payment_type)

A regular function call in the same position already renders correctly.

Fix

Mirror emit_standard_function in emit_coalesce_expr and emit_min_max_expr: soft break after L_PAREN, indent region around the arguments, soft break before R_PAREN. A list that fits keeps rendering on a single line.

ON source_payment_types.value_en =
		COALESCE(
			rent_issuance_parameters_payment_types.value
			, translating.leases.rent_issuance_parameters_payment_type
		)

Tests

  • new fixtures coalesce_expr_1.sql and min_max_expr_1.sql (leading commas, tabs, expanded layout) pin the broken rendering;
  • existing snapshots window_function_group_200 and opr_sanity_80 are updated: they only move the affected COALESCE/greatest calls to the new layout;
  • full pgls_pretty_print suite passes (566 tests), cargo clippy --all-targets clean.

CoalesceExpr and MinMaxExpr emit their argument list without a soft break after the opening parenthesis and without an indent region, unlike emit_standard_function. When the enclosing group breaks, the only break opportunity left is the one before a leading comma, so continuation arguments land at the same indentation as the line that opens the call.

Mirror emit_standard_function: soft break after L_PAREN, indent region around the arguments, soft break before R_PAREN. A list that fits keeps rendering on a single line.
@psteinroe
psteinroe merged commit fc3ec0f into supabase-community:main Oct 8, 2026
9 checks passed
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.

2 participants