sql-formatter-org / sql-formatter-org/sql-formatter

[FORMATTING] Missing indent level of comment after CASE

Open
#698 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
2.9k
Forks
456
Avg merge
3d 4h
Merged PRs (30d)
3

Description

Input data

Which SQL and options did you provide as input?

SELECT
  a,
  CASE
    -- one
    WHEN a = 1 THEN 'one'
    -- two
    WHEN a = 2 THEN 'two'
    ELSE 'other'
  END
FROM
  test;

Expected Output

(unchanged)

SELECT
  a,
  CASE
    -- one
    WHEN a = 1 THEN 'one'
    -- two
    WHEN a = 2 THEN 'two'
    ELSE 'other'
  END
FROM
  test;

Actual Output

-- one is indented one level lesser than expected

SELECT
  a,
  CASE
  -- one
    WHEN a = 1 THEN 'one'
    -- two
    WHEN a = 2 THEN 'two'
    ELSE 'other'
  END
FROM
  test;

Usage

  • How are you calling / using the library? Demo on website
  • What SQL language(s) does this apply to? PostgreSQL
  • Which SQL Formatter version are you using? 15.0.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported input on the SQL Formatter demo website using PostgreSQL settings and compare the comment indentation with the expected output. Trace the formatter path responsible for comments after CASE, then add coverage for this example if the relevant test location is identified; done means the comment remains aligned with the WHEN clauses.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.