nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst
https://nene.github.io/prettier-sql-playground/
GNU General Public License v3.0
123 stars 7 forks source link

Apply format for inline SQL string #25

Closed peterHakio closed 7 months ago

peterHakio commented 7 months ago

In our applications we write raw sql queries like:

const query = `
    UPDATE "my_table"
    SET "base" = tmp.new_valu....
`

We would love to be able to apply sql formating on these.

A suggestion for a way to detect such queries could be if the string starts with-- sql. like this:

const query = `-- sql
    UPDATE "my_table"
    SET "base" = tmp.new_valu....
`

It could be enabled as a opt in feature, where the trigger string could be a variable the user could set in the config.

Other solution ideas would be appreciated :)

nene commented 7 months ago

Please see the embed plugin, as mentioned in the FAQ.