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

[FORMATTING] Confusion between LIMIT keyword and column name

Open
#302 4 comments 0 reactions 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

We have a table with a 'limit' column, when inserting into the table sql-formatter indents characters after the column name.

Input data
Which SQL and options did you provide as input?
options = { language: 'postgresql' };

Expected Output

INSERT INTO
  search (
    apples,
    limit,
    pears,
    oranges
  )
values
  (
    '__apples',
    '__limit',
    '__pears',
    '__oranges'
  );

Actual Output

INSERT INTO
  search (
    apples,
    limit
      , pears,
    oranges
  )
values
  (
    '__apples',
    '__limit',
    '__pears',
    '__oranges'
  );

Usage

  • How are you calling / using the library?
    calling inside a Jest snapshot-serializer
  • What SQL language(s) does this apply to?
    postgresql
  • Which SQL Formatter version are you using?
    I'm using v8.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

Start by reproducing the PostgreSQL INSERT example and trace how the formatter handles the limit column in the column list. Add a regression test for the reported input and expected output, then confirm the formatter no longer moves the following comma and column.

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
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.