SQL Formatting for queryRaw
Problem
My API, as many other I assume, has a couple of complex queries that can't be achieved with Prisma, because of this I'm kind of forced to use queryRaw and write it in plain ole SQL. The problem with this is that the SQL is almost always a mess as there's no way for it to be automatically formatted.
VsCode has a bunch of extensions that allow you to format strings written after an sql tag like this:
sql`<code query here>`
but they don't work with Prisma.
Suggested solution
Ideally a VScode plugin that automatically formats anything written after queryRaw would be perfect. Maybe forking one of the existing plugins would work?
Alternatives
I've used some online formatters but they really really suck 😂
I do the formatting in PopSQL at the moment. It works flawlessly, but copy-pasting SQL from VSCode to another software and back only for formatting feels dumb.
The VSCode formatter/highlighter extension seem to work when you wrap the SQL in Prisma.sql, but that can't be used when you need to dynamically pass in table or column names. Passing in column names is pretty common I suppose for sorting purposes for example so this pretty much renders Prisma.sql useless for this use case.
Closing as a duplicate of https://github.com/prisma/language-tools/issues/74
#74 was closed after syntax highlighting was implemented, but there is still no auto-format available that I know if. Is it available somehow? I'm using VSCode and Prettier by default.
No, that is fair - we implemented highlighting, but not formatting. I'll reopen this issue so we can track that.