question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma does not support SQL Server Schemas

See original GitHub issue

Bug description

Hi,

Prisma does not support SQL Server Schemas, all queries are prefixed with dbo.

[dbo] is the default schema in SQL Server, it does not need to be prefixed against each query. My suggestion is that you drop the dbo prefix when a @@map is used for a table. i.e when you are referencing a table schema.

i.e.

model MyTable {
        MyTableID Int @id @default(autoincrement())
        Description String @unique
        @@map(name: "MySchema.MyTable")
}

does not work because a query of

SELECT MyTableID,Description FROM dbo.MySchema.MyTable

is invalid.

Correct Query would be

SELECT MyTableID,Description FROM MySchema.MyTable

Please could we get a fix this issue or point me to the SQL Generator Module and I could have a look myself. It should be a simple fix.

Many Thanks

Toby.

How to reproduce

Issue a query to a SQL server backend that has a table in a non-dbo schema.

Expected behavior

To be able to issue a query to a SQL server backend that has a table in a non-dbo schema.

Prisma information

Environment & setup

  • OS: Windows
  • Database: Sql Server
  • Node.js version: 16

Prisma Version

prisma                  : 3.4.0
@prisma/client          : 3.4.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash    : 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85
Studio                  : 0.438.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tobimaxcommented, Nov 18, 2021

Thanks for that, I’ll give it a try. Roll on trying to solve the multiple schema scenario, it’s really important.

0reactions
janpiocommented, Jan 31, 2022

Yes, which is why https://github.com/prisma/prisma/issues/1122 exists as I mentioned above and we will sooner or later implement this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft SQL Server Support in Prisma is Generally Available
Today we are excited to announce that Prisma support for SQL Server and Azure SQL is Generally Available and ready for production!
Read more >
Microsoft SQL Server - Prisma
This page explains how Prisma can connect to a Microsoft SQL Server database ... Added as a prefix to all the queries if...
Read more >
Prisma schema API (Reference)
API reference documentation for the Prisma Schema Language (PSL).
Read more >
Prisma 2.10 Adds Preview Support for Microsoft SQL Server
Prisma Migrate does not support SQL Server yet. This means that you can continue using whichever migration tool to alter the database schema...
Read more >
Prisma schema (Reference)
The Prisma schema is the main configuration file when using Prisma. It is typically called schema.prisma and contains your database connection and data ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found