Skip to content

Ability to disable the formatter for a block of SQL #703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mbtolou opened this issue Jan 21, 2024 · 2 comments
Closed

Ability to disable the formatter for a block of SQL #703

mbtolou opened this issue Jan 21, 2024 · 2 comments
Labels

Comments

@mbtolou
Copy link

mbtolou commented Jan 21, 2024

how to ignore formatter for block of sql

like this :


// prettier-ignore
or
-- prettier-ignore

@nene
Copy link
Collaborator

nene commented Jan 21, 2024

SQL Formatter is not Prettier. It has not been developed to be compatible with Prettier. Heck, the first version of SQL Formatter was released before Prettier existed.

I know there exists prettier-plugin-sql, which uses SQL Formatter under the hood, but I have no control over that project.

If you're interested in more Prettier-compatible SQL formatting solution, I suggest you try prettier-plugin-sql-cst. This doesn't support the ignore-comments, but there exists more of a chance that such a feature gets implemented.

In this project, the best one could hope for would be a feature where you mark both start and end of the code you don't want to be formatted, like:

/* sql-formatter-disable */
SELECT * FROM tbl
/* sql-formatter-enable */

There could be a point for implementing something like this, as it would help in working around scenarios where the formatter currently fails to produce a sensible output or even crashes. Like:

@nene nene changed the title prettier ignore not worked! Ability to disable the formatter for a block of SQL Jan 21, 2024
@nene nene closed this as completed in c3ea743 Jan 21, 2024
@nene
Copy link
Collaborator

nene commented Jan 21, 2024

Implemented in 15.1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants