sql-formatter-org / sql-formatter

A whitespace formatter for different query languages
https://sql-formatter-org.github.io/sql-formatter/
MIT License
2.23k stars 392 forks source link

[FORMATTING] array type #742

Closed leelhn2345 closed 1 month ago

leelhn2345 commented 1 month ago

Describe the bug

formatting error occurs when [] is in the code.

create table projects (

id serial primary key not null,

subscriptions text[]

);

Expected behavior

expected the formatted output to be like below

create table projects (
  id serial primary key not null,
  subscriptions text[]
);

Actual behavior

i have the error

Error: Parse error: Unexpected "[]
);"

my current alternative is

create table projects (
  id serial primary key not null,
  subscriptions text array
);

Usage

nene commented 1 month ago

Just select the PostgreSQL dialect when formatting. Please read the FAQ.