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

Incorrect indentation in PostgreSQL `DELETE FROM ... USING`

Open
#683 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the Feature

More consistent formatting for multiple joined tables after the USING keyword in a DELETE FROM ... USING query (consistent compared to SELECT ... FROM ... JOIN:

Input data

Which SQL and options did you provide as input?

DELETE FROM films
USING
  producers,
  sessions
WHERE sessions.id = '123' AND producer_id = producers.id AND producers.name = 'foo';

Expected Output

DELETE FROM
  films
  USING
    producers,
    sessions
WHERE
  sessions.id = '123'
  AND producer_id = producers.id
  AND producers.name = 'foo';

Actual Output

DELETE FROM films USING producers,
sessions
WHERE
  sessions.id = '123'
  AND producer_id = producers.id
  AND producers.name = 'foo';

Why do you want this feature?

To be more consistent with the SELECT ... FROM ... JOIN formatting:

SELECT
  *
FROM
  candidates
  INNER JOIN sessions ON users.session_id = sessions.id

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

No source file or test is named in the issue. Reproduce the provided DELETE FROM ... USING input and trace the formatter entry point for joined tables, comparing it with SELECT ... FROM ... JOIN handling; the work is done when the output matches the expected indentation without changing the WHERE formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, typescript
Domain
tooling
Issue type
Feature
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.