un-ts / prettier

:package: Opinionated but Incredible Prettier plugins.
https://prettier.vercel.app
MIT License
274 stars 25 forks source link

Unable to format SQL: Error: Parse error: Unexpected "{env}_s3_d" #277

Closed chriskathumbi closed 11 months ago

chriskathumbi commented 1 year ago

Unable to format SQL: Error: Parse error: Unexpected "{env}_s3_datalake.{". This is for parameterized SQL to query multiple tables like: SELECT *, current_date - interval {interval} {period} FROM {database_name}.{table_name}

It seems to fail due to the use of '{' , '}' Using ' ` ' doesn't help due to some dialects not supporting it Is it possible to add char ignore or add a custom sql dialect for this sort of query?

JounQin commented 1 year ago

Please provide a runnable reproduction like GitHub repo.

JounQin commented 11 months ago

This should be reported to https://github.com/sql-formatter-org/sql-formatter instead.

cc @nene


https://github.com/un-ts/prettier/blob/a8a0ff495b4984928e69f317616196fc21808f2f/packages/sql/package.json#L48

And it seems we are outdated now, sql-formatter v13 has been released, PR welcome to upgrade it and test your failing case.

nene commented 11 months ago

Templating is not directly supported in SQL Formatter, a workaround is to use paramTypes config option.