sql-formatter-org / sql-formatter

A whitespace formatter for different query languages
https://sql-formatter-org.github.io/sql-formatter/
MIT License
2.37k stars 405 forks source link

Feature Request: Detect dialect inside a comment or filename #764

Open kermes opened 3 months ago

kermes commented 3 months ago

Describe the Feature just like the /* sql-formatter-disable */ feature, would love to be able to specify the dialect inside a comment before the query. Maybe something like /* sql-formatter-dialect: postgresql */ in the first line of the file.

Why do you want this feature? Specially in vscode extension, where one project can have multiple dialects in different files but you're currently forced to choose one only for the whole project in the extension settings

Alternative Another solution could be to identify the dialect in the filename, so myquery.snowflake.sql or even myquery.postgresql could be used to pick the correct dialect.