sql-formatter icon indicating copy to clipboard operation
sql-formatter copied to clipboard

missing -- sql comment support for disable formatting

Open lil5 opened this issue 4 months ago • 1 comments

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)

lil5 avatar Oct 21 '25 12:10 lil5

Well, according to the documentation (and my testing) MariaDB supports /* */ comments just fine.

https://mariadb.com/docs/server/reference/sql-statements/comment-syntax

nene avatar Oct 21 '25 14:10 nene