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

[FORMATTING] PostgreSQL TYPE keyword used as identifier causes indentation errors #685

Closed
karlhorky opened this issue Dec 5, 2023 · 1 comment
Labels

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Dec 5, 2023

Input data

Which SQL and options did you provide as input?

SELECT
  items.id,
  'project' AS type,
  items.created_at,
  items.modified_at
FROM
  items;

Expected Output

(no formatting change)

SELECT
  items.id,
  'project' AS type,
  items.created_at,
  items.modified_at
FROM
  items;

Actual Output

TYPE keyword causes subsequent lines to move down without indentation

SELECT
  items.id,
  'project' AS
type,
items.created_at,
items.modified_at
FROM
  items;

Usage

  • How are you calling / using the library? Website demo
  • What SQL language(s) does this apply to? PostgreSQL
  • Which SQL Formatter version are you using? 14.0.0

Hypothesis

Maybe the '[SET DATA] TYPE' array item in onelineClauses or the 'TYPE' keyword have something to do with it

Related issues

@karlhorky karlhorky added the bug label Dec 5, 2023
@nene
Copy link
Collaborator

nene commented Dec 6, 2023

Indeed, this [SET DATA] TYPE rule is the cause of this. Probably best to drop support for the shorthand syntax and only detect SET DATA TYPE.

Another part is the TYPE keyword itself. This will affect the keywordCase option and is indeed essentially the same issue as #302

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

No branches or pull requests

2 participants