prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
38.8k stars 1.52k forks source link

Cannot pass `NULL` to stored procedure via raw query #19471

Open manika-khare opened 1 year ago

manika-khare commented 1 year ago

Bug description

I am trying to call a stored procedure using prisma's queryRaw. The stored procedure accepts a parameter of type unqiueidentifier which can be null. It works fine when the param has some value, but it fails when null is passed.

It throws the following error:

Raw query failed. Code: `206`. Message: `Operand type clash: int is incompatible with uniqueidentifier`

How to reproduce

Expected behavior

It should run fine even when null is passed, as the stored procedure allows null.

Prisma information

// Add your schema.prisma
// Add your code using Prisma Client
prisma.$queryRaw`
    EXEC myStoredProc @name = ${name}, @id = ${id}
`

Environment & setup

Prisma Version

prisma                  : 4.13.0
@prisma/client          : 4.13.0
janpio commented 3 months ago

@manika-khare Can you please share the definition of the (or a reproduction example) stored procedure so we can play with this ourselves? Does the query work when you execute it manually via another database client?

ayloncarrijo commented 2 weeks ago

Same here. This only occurs when using SQL Server.