Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DROP IDENTITY, OVERRIDING SYSTEM VALUE to PostgreSQL clauses #820

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

karlhorky
Copy link
Contributor

@karlhorky karlhorky commented Jan 5, 2025

Hey @nene, hope you're great! 👋 Happy New Year!

Quick PR to recognize DROP IDENTITY and OVERRIDING SYSTEM VALUE as one-line clauses

With the configuration:

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

This makes the following change:

DROP IDENTITY

-- Before PR #820
ALTER TABLE events
ALTER COLUMN id
DROP identity;

-- After PR #820
ALTER TABLE events
ALTER COLUMN id
DROP IDENTITY;

OVERRIDING SYSTEM VALUE

-- Before PR #820
INSERT INTO
  events (
    id,
    title,
    description
  ) overriding system value
VALUES
  (
    1,
    'abc',
    'def'
  );

-- After PR #820
INSERT INTO
  events (
    id,
    title,
    description
  )
OVERRIDING SYSTEM VALUE
VALUES
  (
    1,
    'abc',
    'def'
  );

Copy link

codesandbox-ci bot commented Jan 5, 2025

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
Copy link
Collaborator

nene commented Jan 5, 2025

Thanks. This is useful.

However I should point out that using identifierCase: lower is really just asking for trouble. See the docs for clarification. There's a reason this configuration option is marked as experimental.

@nene nene merged commit 9fe19f9 into sql-formatter-org:master Jan 5, 2025
2 checks passed
@karlhorky
Copy link
Contributor Author

karlhorky commented Jan 5, 2025

Thanks for the review and merge!

Interesting, I see that the commit f4cda21 adding this explanation was motivated by #809 (hi again @gajus 👋)

Personally, I want this behavior - everything by default lowercase, and then the recognized keywords as uppercase. As such, I would personally evaluate each of these cases as (minor) bugs in SQL Formatter's dialects and keyword detection.

Opened a new PR for these particular cases mentioned by @gajus:

@karlhorky karlhorky deleted the patch-1 branch January 5, 2025 12:56
@karlhorky
Copy link
Contributor Author

Thanks also for the release in [email protected], can confirm it's working 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants