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

missing -- sql comment support for disable formatting

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

Nobody has claimed this yet.

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

Description

https://github.com/sql-formatter-org/sql-formatter/blob/976f97df76b0d44a77fb37b703d85be889457da8/src/lexer/Tokenizer.ts#L37

In MariaDB you can't use /* comment */ and need to use -- comment to disable formatting in mariadb sql files for queries, it would be handy to be able to use -- instead like so:

SELECT
-- sql-formatter-disable
  sqlc.embed(users),
-- sql-formatter-enable
  customers.id
FROM
  customers
  JOIN users ON users.customer_id = customers.id

My personal issue is the issue that this formatter adds a space after embed for my golang sqlc project (see #913)

--- sqlc.embed(users)
+++ sqlc.embed (users)

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 at src/lexer/Tokenizer.ts#L37 and trace how formatting-disable and formatting-enable comments are recognized. Support the requested -- marker form for MariaDB SQL, preserving the existing behavior for block comments, and verify the example remains unchanged between the markers.

Written by the indexing model from the issue text.

Assessment

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