Open felixfbecker opened 4 months ago
Thanks for reporting.
This dense formatting of :
is currently done to improve the formatting of array-slice operations (related to #624):
SELECT foo[1:5];
Unfortunately this is tricky to fix with the current architecture. When I improve it for JSON_OBJECT
, it'll become worse for array-slice.
There's much more hope of doing better JSON_OBJECT()
formatting in prettier-plugin-sql-cst where it currently though produces a hard crash.
When you use the
JSON_OBJECT()
function from the SQL standard (implemented in PostgreSQL 16), the formatter removes/does not insert a space between the:
delimiting the key and value, which makes the SQL somewhat hard to read.Input data
Which SQL and options did you provide as input?
Expected Output
Actual Output
This may not seem that big of a deal for a simple example like this, but when the value is a more complicated expression with nested objects etc it becomes much worse.
Usage
JSON_OBJECT()