Closed mcandre closed 3 years ago
+1 on this
From testing this with PosgreSQL, the main issue seems to be the placeholder support.
Placeholders get disjointed:
INSERT INTO
"user"("first_name", "last_name", "is_admin")
VALUES
($ 1, $ 2, $ 3) RETURNING "id",
"is_admin"
Should be:
INSERT INTO
"user"("first_name", "last_name", "is_admin")
VALUES
($1, $2, $3)
RETURNING
"id", "is_admin"
For me, the main issue would be dollar-quoted strings, with extra work required in the tokenizer (because the start/token is variable). As of commit 2f3e9a88441a7084f56aedf32c5ec26b5362389d, using StandardSqlFormatter:
Expected value to be (using ===):
"SELECT $a$String example: $$Hello world!$$ - Did it work?$a$"
Received:
"SELECT
$ a $ String example: $ $ Hello world ! $ $ - Did it work ? $ a $"
Initial postgresql support has now been released in 4.0.0-beta.1
.
To enable it, one can pass "postgresql"
as language option:
format("SELECT *", {language: "postgresql"});
Could sql-formatter support PostgreSQL syntax?