-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: SQL in SQL prettification #44
Comments
If language So I think this should be a feature request for |
Gotcha, ty for explaining |
You should post a feature request at https://github.com/sql-formatter-org/sql-formatter or https://github.com/nene/prettier-plugin-sql-cst. |
There's nothing we can do in this repo currently, so let's track this feature in the following links: |
I am guessing that you will probably find this to be out of scope of your plugin, but maybe not, so I figure I'd ask:
If you are writing SQL functions, it's pretty common to have SQL embedded inside SQL; for example (straight out of Postgres documentation):
In this case,
$$
is a string quoting delimiter, andSELECT $1, CAST($1 AS text) || ' is text'
is a quoted string.The issue is that most SQL formatters (and in particular, the one used by
prettier-plugin-embed
do not recurse into these quoted string function bodies, so the function declaration is prettified but the function implementation remains ugly. Here's what I get if I run the above throughprettier
withprettier-plugin-sql
(regardless of whetherprettier-plugin-embed
is on):What I wish I got would be more like
(That's what I get if I manually run the function body through
prettier-plugin-sql
and then paste it inside$$
delimiters.Now, on the one hand, I realize that the description of
prettier-plugin-embed
specifically says that its only intent is to handle tagged strings in TS/JS, so if you just want to turn this idea away, I get that. But if you're looking for another cool thing to do in the realm of embedded string prettification, well, then I think this one is a good candidate 🙂The text was updated successfully, but these errors were encountered: