Feature Request: Detect dialect inside a comment or filename

Open
#764 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
sql, typescript, vscode

Research direction

No files or tests are named. Start by tracing the existing sql-formatter-disable comment handling and the VS Code extension's project-wide dialect setting; clarify whether comment detection, filename detection, or both are in scope, then define tests showing that each file selects its intended dialect.

Written by the indexing model from the issue text.

Description

feature

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.

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

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.

More from sql-formatter-org/sql-formatter

All issues in sql-formatter-org/sql-formatter

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.