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] column name "match" is converted to uppercase. #740

Open krishnagogada opened 1 month ago

krishnagogada commented 1 month ago

Input data

Which SQL and options did you provide as input?

create table player_match_details(
  name varchar(150),
  match varchar(150),
  score int
);

Expected Output

CREATE TABLE player_match_details(
  name varchar(150),
  match varchar(150),
  score int
);

Actual Output

CREATE TABLE player_match_details(
  name varchar(150),
  MATCH varchar(150),
  score int
);

Usage

nene commented 1 month ago

Thanks for reporting. This is similar to #302 and #732.

One one hand this is really a fundamental problem with SQL Formatter that can't be easily fixed. (I could remove MATCH from list of keywords and then we'd have the opposite problem).

On another hand, you would be better off not using the default language:"sql". If possible choose the value that matches the SQL dialect you're actually using, like language: "postgresql". That other dialect might or might not have MATCH in its list of keywords.

FYI, there are no uppercase and indent options in latest SQL Formatter. You're either using some old version or some other tool altogether.

krishnagogada commented 1 month ago

@nene

Thanks for the reply, I kept the specific language SQLite, even though I have the issue. Is there any alternative fix?

nene commented 1 month ago

An alternative is to use a different formatting library which doesn't have this issue: https://github.com/nene/prettier-plugin-sql-cst