Skip to content

[FORMATTING] Missing space after colon in JSON_OBJECT(key: value) #761

Open
@felixfbecker

Description

@felixfbecker

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?

SELECT JSON_OBJECT(
  'key': 'value',
  'key2': my_table.my_column
)

Expected Output

SELECT JSON_OBJECT(
  'key': 'value',
  'key2': my_table.my_column
)

Actual Output

SELECT JSON_OBJECT(
  'key':'value',
  'key2':my_table.my_column
)

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

  • How are you calling / using the library? Prettier
  • What SQL language(s) does this apply to? PostgreSQL but presumably all DBs that support JSON_OBJECT()
  • Which SQL Formatter version are you using? 15.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions