prisma / language-tools

🌐 Prisma Language Tools = Language Server and Prisma's VS Code extension.
https://marketplace.visualstudio.com/items?itemName=Prisma.prisma
Apache License 2.0
255 stars 36 forks source link

Additional Syntax Highlighting of SQL in Prisma Client raw queries #1219

Open Jolg42 opened 2 years ago

Jolg42 commented 2 years ago

We recently released 4.2.0 where we now have highlighting for the following, only:

$queryRaw`` & $executeRaw``

We could support more cases like:

P4sca1 commented 2 years ago

Specifying the return type is currently not supported and leads to syntax highlighting getting lost.

$queryRaw<ReturnType>`my query`
Jolg42 commented 2 years ago

@P4sca1 It works for me 🤔, could you check which version of VS Code and the Prisma VS Code extension you have?

Screenshot 2022-08-19 at 14 18 11
P4sca1 commented 2 years ago

@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
`
Jolg42 commented 2 years ago

Indeed, I can reproduce this, thanks for the example 👍🏼

arthurfiorette commented 1 year ago

Could we get some sort of autocompletion too?

prisma.model.$executeRaw`UPDATE ${ctrl space -> shows prisma model names}`
janpio commented 1 year ago

Optimally open a new issue for this @arthurfiorette - that would need to be implemente separately.

ctsstc commented 11 months ago

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

janpio commented 11 months ago

This is the meat of the PR that resolves #74: https://github.com/prisma/language-tools/pull/985/files#diff-fdb153efde4d632bf09e6ca7edb77120f2a1d8f888aae21f62d2743682c67a3e

karlhorky commented 8 months ago

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:

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 `):

marnixhoh commented 6 months ago

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

rush42 commented 2 weeks ago

Any news on this, or hints where to contribute ? Would love to have this for $queryRaw(), $executeRaw(), $queryRawUnsafe() and $executeRawUnsafe() .