sql-formatter icon indicating copy to clipboard operation
sql-formatter copied to clipboard

[FORMATTING]Postgresql Function body is not getting formatted

Open ZachStoltz opened this issue 3 years ago • 2 comments

CREATE OR REPLACE FUNCTION my_fn() RETURNS json AS
$BODY$

SELECT test, blah, yah, another, tehe from t_table

$BODY$
LANGUAGE sql VOLATILE
COST 100;

used via prettier-plugin-sql -> sql-formatter version: 10.7.2 Tried the above example at https://sql-formatter-org.github.io/sql-formatter/ as well

ZachStoltz avatar Jan 27 '23 15:01 ZachStoltz

This is by design because the body might be written in all sort of languages besides SQL. The formatter treats the body as a string and does not touch the contents.

This behavior is unlikely to change with the current architecture of the formatter. I'm working on a new SQL formatting library, which in theory should be able to tackle this problem, but this is still in very early stages of development.

nene avatar Jan 27 '23 15:01 nene

Closing this as the current behaviour is sort-of by design. Plus it's not feasible to fix in the current architecture.

nene avatar Feb 17 '23 13:02 nene