Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SQL Server in executeRaw and queryRaw #3861

Closed
pimeys opened this issue Oct 6, 2020 · 2 comments · Fixed by #3965
Closed

Support SQL Server in executeRaw and queryRaw #3861

pimeys opened this issue Oct 6, 2020 · 2 comments · Fixed by #3965
Assignees
Labels
kind/feature A request for a new feature. tech/typescript Issue for tech TypeScript. topic: prisma-client topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli topic: sql server Microsoft SQL Server

Comments

@pimeys
Copy link
Contributor

pimeys commented Oct 6, 2020

We need to parameterize the queries correctly. Different for MySQL and SQLite using ? and PostgreSQL using $1, $2 etc for parameter substitution, SQL Server has the @P1, @P2 and so on where the number marks the parameter position as we do with PostgreSQL.

This should be handled in our client so the raw queries will not panic out immediately.

@Jolg42 Jolg42 added kind/feature A request for a new feature. tech/typescript Issue for tech TypeScript. topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli labels Oct 6, 2020
@janpio janpio added this to the Backlog 2.10.0 milestone Oct 14, 2020
@timsuchanek
Copy link
Contributor

Created an issue in blakeembrey/sql-template-tag#18

@sdnts
Copy link
Contributor

sdnts commented Oct 15, 2020

I'm going to be picking this up, so I looked into this a little, and here are my observations:

  1. The reason you need sql-template-tag with the pg & msql libraries is because they do not support prepared statements natively.
  2. It looks like https://github.com/tediousjs/node-mssql is the "official" client (kinda, at least it is what https://docs.microsoft.com/en-us/sql/connect/node-js/node-js-driver-for-sql-server?view=sql-server-ver15 points to). This is also called mssql on NPM.
  3. mssql has support for prepared statements out of the box, so there's little need for sql-template-tag with it.
  4. What I mean is that the issue @timsuchanek created is irrelevant. sql-template-tag cannot "support" mssql because mssql does not allow you to hook into their query logic. They do not support sending prepared statements without using their in-built classes / abstractions.

In order to accomplish this, we (prisma) would need to create these prepared statements ourselves rather than put it in sql-template-tag (because putting it there makes no sense)

Should I explain the same on blakeembrey/sql-template-tag#18 and close it? I can work on adding prepared statement support for MSSQL in here.

TL;DR: We should put code for generating prepared statements for MSSQL in prisma/prisma, not in sql-template-tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. tech/typescript Issue for tech TypeScript. topic: prisma-client topic: raw $queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli topic: sql server Microsoft SQL Server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants