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

Add primary key, generated column reserved phrases #714

Closed karlhorky closed 5 months ago

karlhorky commented 5 months ago

Add reserved phrases for PostgreSQL for primary keys and generated columns

After this change, the formatting results in the common style in the ecosystem:

CREATE TABLE animals (
  id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY
);

Before, the following configuration would result in the mixed lowercase for KEY, GENERATED, ALWAYS, and IDENTITY:

CREATE TABLE animals (
  id integer PRIMARY key generated always AS identity
);

Config (attempt to match style of official PostgreSQL docs):

{
  language: 'postgresql',
  keywordCase: 'upper',
  identifierCase: 'lower',
  dataTypeCase: 'lower',
  functionCase: 'lower',
}

This was caused by the PostgreSQL keywords being removed in:

codesandbox-ci[bot] commented 5 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

nene commented 5 months ago

Thanks.

karlhorky commented 5 months ago

Glad to help, thanks for the review and merge 🙌