language-tools
language-tools copied to clipboard
Additional Syntax Highlighting of SQL in Prisma Client raw queries
We recently released 4.2.0
where we now have highlighting for the following, only:
$queryRaw`` & $executeRaw``
We could support more cases like:
- [ ]
$queryRaw()
,$executeRaw()
,$queryRawUnsafe()
,$executeRawUnsafe()
using parenthesis()
- [ ]
sql
,raw
(join
,empty
), from https://github.com/blakeembrey/sql-template-tag that can be used from The Prisma Client (see example)
Specifying the return type is currently not supported and leads to syntax highlighting getting lost.
$queryRaw<ReturnType>`my query`
@P4sca1 It works for me 🤔, could you check which version of VS Code and the Prisma VS Code extension you have?
@Jolg42 I checked again and found why it is not working for me.
// This works
prisma.$queryRaw<{ id: number }[]>`
SELECT id from machine
`
// This does not work, because the return type declaration spans multiple lines
prisma.$queryRaw<{
id: number
}[]>`
SELECT id from machine
`
Indeed, I can reproduce this, thanks for the example 👍🏼
Could we get some sort of autocompletion too?
prisma.model.$executeRaw`UPDATE ${ctrl space -> shows prisma model names}`
Optimally open a new issue for this @arthurfiorette - that would need to be implemente separately.
Landed on this issue looking for highlighting support for code that has been abstracted out to: Prisma.sql
. I really enjoyed the highlighting when I had it jammed into the $queryRaw
It seems like we have support for $queryRaw
from https://github.com/prisma/language-tools/issues/74
This is the meat of the PR that resolves #74: https://github.com/prisma/language-tools/pull/985/files#diff-fdb153efde4d632bf09e6ca7edb77120f2a1d8f888aae21f62d2743682c67a3e
This does not work, because the return type declaration spans multiple lines
@P4sca1 The lack of syntax highlighting after multi-line generic arguments is a problem with VS Code and TextMate grammars not being able to span across multiple lines:
- https://github.com/microsoft/vscode-textmate/issues/41
However, a workaround exists for many syntax highlighting extensions (such as SQL tagged template literals by @frigus02), to use a comment (such as /* sql */
) between the generic arguments list and the template string (after the >
and before the `
):
- https://github.com/frigus02/vscode-sql-tagged-template-literals/issues/20#issuecomment-1817902214
Hi! I really like the syntax highlighting for $queryRaw
& $queryExecute
. Just wondering if there are any plans to support it too for sql
& raw
anytime soon?
Thank you so much