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

[FORMATTING] postgresql timestamp datatype on create table adds unnecessary newline

Open alarbada opened this issue 3 years ago • 1 comments

Input data Which SQL and options did you provide as input?

create table test (
	a int,
	b int,
	c TIMESTAMP with time zone,
	d int
);

Expected Output

CREATE    TABLE test (
                    a INT,
                    b INT,
                    c TIMESTAMP WITH TIME ZONE,
                    d INT
                    );

Actual Output

CREATE    TABLE test (
                    a INT,
                    b INT,
                    c TIMESTAMP
                    WITH      TIME ZONE,
                              d INT
                    );

Usage

  • How are you calling / using the library? By coc-sql
  • What SQL language(s) does this apply to? postgresql
  • Which SQL Formatter version are you using? latest with coc-sql

alarbada avatar Aug 12 '22 10:08 alarbada

The with keyword causes the issue. Trying with timestamp without time zone looks fine.

alarbada avatar Aug 12 '22 11:08 alarbada

This is similar to #340

  • The formatter shouldn't attempt to detect a WITH-clause inside a CREATE TABLE statement.
  • Like in #340 the formatter shouldn't detect UPDATE statement inside a SELECT.

No quick fix available for it, but we're moving towards a better architecture to solve this.

nene avatar Aug 12 '22 12:08 nene

Found a simpler way of fixing this. Released in 10.2.0.

nene avatar Sep 01 '22 11:09 nene