P
Prisma4mo ago
switz

nested raw query errors

WHERE
"postId" = ${postId} AND
${rootCommentId ? `"id" = ${rootCommentId}` : '"parentCommentId" IS NULL'}
WHERE
"postId" = ${postId} AND
${rootCommentId ? `"id" = ${rootCommentId}` : '"parentCommentId" IS NULL'}
I get
Message: `ERROR: argument of AND must be type boolean, not type text
Message: `ERROR: argument of AND must be type boolean, not type text
Do I need to escape this further?
Solution:
What version of Prisma ORM are you using? Have you tried TypedSQL? https://www.prisma.io/blog/announcing-typedsql-make-your-raw-sql-queries-type-safe-with-prisma-orm
Prisma
Announcing TypedSQL: Make your raw SQL queries type-safe with Prism...
Prisma ORM now supports the ability to write raw sql queries and have the inputs and outputs be fully type-safe! Get the benefit of a high-level API with the power of raw SQL.
Jump to solution
3 Replies
switz
switzOP4mo ago
I guess i have to use prisma.raw but is there a way to do that and escape rootCommentId
Solution
jonfanz
jonfanz4mo ago
What version of Prisma ORM are you using? Have you tried TypedSQL? https://www.prisma.io/blog/announcing-typedsql-make-your-raw-sql-queries-type-safe-with-prisma-orm
Prisma
Announcing TypedSQL: Make your raw SQL queries type-safe with Prism...
Prisma ORM now supports the ability to write raw sql queries and have the inputs and outputs be fully type-safe! Get the benefit of a high-level API with the power of raw SQL.
switz
switzOP4mo ago
"@prisma/client": "^5.4.1",
"@prisma/client": "^5.4.1",
this is really cool, let me play with this nice, I got it working this is awesome, tyvm is there a good way to export the type?
type DepthComment = get_comments.Result;
type DepthComment = get_comments.Result;
got it
Want results from more Discord servers?
Add your server