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.

multiSchema does not work with SQL Server schemas with dot in name (= databases)

See original GitHub issue

Bug description

In sqlserver when declaring several schemas, it was not possible to perform a select. There was a table not found error in the database

How to reproduce

(https://github.com/prisma/prisma/issues/15077#issuecomment-1270280714)

Expected behavior

No response

Prisma information

Its work

datasource db {
    provider = "sqlserver"
    url      = env("DATABASE_URL")
    schemas  = ["database1].[dbo", "database2].[dbo"]
}

Does not work

datasource db {
    provider = "sqlserver"
    url      = env("DATABASE_URL")
    schemas  = ["database1", "database2"]
}
prismaClient.table1.findMany()

Environment & setup

  • OS: Windows
  • Database: SQL Server
  • Node.js version: v16.14.0

Prisma Version

v4.4.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
janpiocommented, Oct 7, 2022

Yeah, that makes sense. You “hacked” our system 👍 😆

I fear we will probably have to limit that first, before we can properly enable this. Right now the foreign keys are a important requirement for a relation in Prisma. We will open that up sooner or later, and then that would also enable doing multiDatabase for SQL Server with databases on the same server.

0reactions
pimeyscommented, Dec 19, 2022

Naturally this breaks in every engine. Here’s what introspection engine gives us:

Incorrect syntax near '.'. code=102
Error: Incorrect syntax near '.'.
   0: sql_migration_connector::apply_migration::migration_step
           with step=CreateSchema(NamespaceId(0))
             at migration-engine/connectors/sql-migration-connector/src/apply_migration.rs:21
   1: sql_migration_connector::apply_migration::apply_migration
             at migration-engine/connectors/sql-migration-connector/src/apply_migration.rs:10
   2: migration_core::state::SchemaPush
             at migration-engine/core/src/state.rs:402

We do not support multi-database schemas with any database. But, you should try out Prisma 4.8.0 tomorrow that does let you to migrate and introspect multi-schema databases with SQL Server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it okay to put dots in SQL Server database names?
However choosing a database that contains a dot will produce an error stating that the server could not be found. It seems that...
Read more >
Entity Framework and multiple schemas - Stack Overflow
I'm trying to set up my dbContext so that it can handle multiple schemas in a single Oracle database.
Read more >
"Invalid object name" when trying to read tables from multi ...
In FME Workbench I have a MS SQLServer database that has multiple schemas. Schema1.Schema2.Tablename. Workbench sees the tables in the ...
Read more >
Import table failed when schema name contains dot character ...
If the table is not in the current database the name must be qualified ... when schema name contains dot character with Microsoft...
Read more >
Documentation: 15: 5.9. Schemas - PostgreSQL
Unlike databases, schemas are not rigidly separated: a user can access objects in ... name consisting of the schema name and table name...
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