Skip to content

fix(formatter): add proper newlines for function bodies#682

Merged
psteinroe merged 1 commit intomainfrom
fix/sql-fn-bodies
Feb 12, 2026
Merged

fix(formatter): add proper newlines for function bodies#682
psteinroe merged 1 commit intomainfrom
fix/sql-fn-bodies

Conversation

@psteinroe
Copy link
Copy Markdown
Collaborator

@psteinroe psteinroe commented Feb 12, 2026

Summary

Improves pretty printing of SQL function bodies by placing dollar-quote delimiters on their own lines for better readability.

Changes

  • Added new token types DOLLAR_QUOTE_DELIMITER and DOLLAR_QUOTE_BODY to separately represent delimiter and content
  • Modified emit_dollar_quoted_str_with_hint to emit delimiters and body on separate lines
  • Added AST normalization for function body whitespace to ensure semantic equivalence in tests

Example

Before

create function add(a int, b int)
returns int
as $function$SELECT $1 + $2$function$
language sql;

After

create function add(a int, b int)
returns int
as $function$
SELECT $1 + $2
$function$
language sql;

This applies to all dollar-quoted function/procedure bodies including CREATE FUNCTION, CREATE PROCEDURE, and DO blocks.

@psteinroe psteinroe merged commit f2056fc into main Feb 12, 2026
9 checks passed
@psteinroe psteinroe deleted the fix/sql-fn-bodies branch February 12, 2026 21:45
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