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

[FORMATTING] Formatter Adds Unwanted Space Before Dash and Number in Project Names (e.g., project -12345)

Open
#791 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Screenshot 2024-10-22 at 9 20 17 AM

Whenever a project name contains a dash followed by a number then it is being interpreted as a minus number value and being separated when formatted. This is troublesome for us as a lot of our project names contain this format and the formatter is breaking our queries as a result.

We can't always rely on escaping the project name as these queries are written by end users in the browser.

Input data

-- BigQuery
select * from project-12345.table.column

Expected Output

select
  *
from
  project-12345.table.column

Actual Output

select 
  *
from
  project -12345.table.column

Usage

  • What SQL language(s) does this apply to?
    BigQuery
  • Which SQL Formatter version are you using?
    15.4.5

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 BigQuery example with sql-formatter 15.4.5 and compare the expected and actual output shown in the issue. Trace the BigQuery formatting path to find where project-12345 is split around the dash, then verify that the formatted query preserves project-12345 and does not insert a space.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.