Closed jgeurts closed 3 months ago
Thanks for reporting.
This is essentially the same issue as #302. Though something else also goes wrong here. TEXT
should be detected as data-type, but is for some reason currently detected as plain keyword.
There's currently no good way to fix this fundamental problem in SQL Formatter. Basically the choices are:
text
as data-type keyword, resulting in CREATE TABLE foo (TEXT TEXT)
text
as identifier, resulting in CREATE TABLE foo (text text)
Though the latter would only happen if you were to use identCase: "lower"
.
But currently something goes wrong in here with the classification of the word text
. Aha... I found the problem. The word text
is also classified as a function name. It is first detected as a function name, and then all the function names are checked for a (
after them, and if there is none, they get turned to plain keywords. Should probably just remove text
from list of function names.
However, as you're already using Prettier, I suggest you instead give a try to prettier-plugin-sql-cst, which does a much better job at formatting PostgreSQL and is actually using the Prettier layout algorithm, unlike prettier-plugin-sql
which is just a thin wrapper around this library which has no connection to Prettier.
Input data
Which SQL and options did you provide as input?
Language:
PostgreSQL
Keyword case:Upper
Expected Output
Actual Output
Usage