Skip to content

Allow defining custom quote types #503

@verhovsky

Description

@verhovsky

Describe the Feature
Allow defining a custom quote type for a dialect.

Why do you want this feature?
As I explained in #306, I would like to define a custom grammar of Trino SQL queries + {{Handlebars templates}} so that users can write (and format with sql-formatter) queries like this

select
  {{ country_code }}
from
  my_table

and we could render the query for other users with a dropdown in place of {{ country_code }}. The easiest way to do this is to make make sql-formatter treat {{}} like a type of string. In order to do this, we need to have a regex for this type of quote in quotePatterns. It makes no sense to add this to sql-formatter itself, so we have to fork it to add this custom quote type. It would be nice if I could pass the regex somehow through DialectOptions' tokenizerOptions.stringTypes or some other way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions