Closed jonatanschroeder closed 4 months ago
Thanks for reporting.
This can probably be patched in sql-formatter. Though there are many scenarios like that where it fails.
If you want a Prettier plugin to format PostgreSQL, I suggest you try prettier-plugin-sql-cst. It does not yet support full PostgreSQL syntax, but it should work for most of the common scenarios (this issue tracks the current progress of PostgreSQL support) and it does an overall better job at formatting than SQL Formatter will ever be capable of.
Thanks for the quick reply.
About the Prettier plugin, I just did a quick check, and it seems to work well in most cases, but there are some cases that it does not support which we use in our case, such as types (CREATE TYPE
), DO
code statements, FULL JOIN
, and a few minor constructs. Also, the fact that it's in experimental stage means it's probably a good idea for us to stick with the custom plugin package has been working for us for the last 12 months until this package is in a more stable setting. That said, it looks promising, and it's likely something to consider in a future release. Also, some of the formatting choices in that plugin seem to me (personally) to make a bit more sense than the ones used in sql-formatter.
Thanks for the feedback. Always good to learn which actual features, that people are using, are missing. I can then possibly prioritize these before others.
Input data
Which SQL and options did you provide as input?
options:
Expected Output
The main issue is that
DEFAULT VALUES
should be treated as a unit, as it is distinct from the usualVALUES
or the query that typically followsINSERT INTO
.Actual Output
Usage