DATABASE_URL verification still attempted when datasource override provided in PrismaClient constructor
See original GitHub issueBug description
https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/constructor#datasources
When attempting to connect to the prisma client which is configured with an explicit datasource location:
const prisma = new PrismaClient({
datasources: { postgresql: { url: "postgres://****:****@localhost:5432/****?schema=foo" } },
});
...
await prisma.$connect();
I get the following error:
(node:99546) UnhandledPromiseRejectionWarning: Error: error: Environment variable not found: DATABASE_URL.
--> schema.prisma:5
|
4 | datasource postgresql {
5 | url = env("DATABASE_URL")
|
Validation Error Count: 1
at Oe.Yu.default.on.c (/Users/timleslie/src/prisma-issue/node_modules/@prisma/client/engine-core/src/NodeEngine.ts:591:29)
at Oe.emit (events.js:197:13)
at Oe.EventEmitter.emit (domain.js:439:20)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Oe.Readable.push (_stream_readable.js:224:10)
at Oe.Transform.push (_stream_transform.js:151:32)
at Oe._pushBuffer (/Users/timleslie/src/prisma-issue/node_modules/@prisma/client/engine-core/src/byline.ts:116:17)
at Oe._transform (/Users/timleslie/src/prisma-issue/node_modules/@prisma/client/engine-core/src/byline.ts:107:8)
at Oe.Transform._read (_stream_transform.js:190:10)
(node:99546) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:99546) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
How to reproduce
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource postgresql {
url = env("DATABASE_URL")
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @default(autoincrement())
name String?
}
Expected behavior
I would expect the client to never look for the DATABASE_URL
environment variable if the override has been provided.
Environment & setup
- OS: OSX 10.15.6
- Database: PostgreSQL 12.2
- Node.js version: 12.11.0
- Prisma version: 2.7.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Prisma Client API (Reference)
datasources. Programmatically overrides properties of the datasource block in the schema.prisma file - for example, as part of an integration test ...
Read more >How to fix Prisma Client getting undefined for custom model
To resolve that, I added a custom path for generating the prisma client inside the schema.prisma file as below - generator client {...
Read more >Adding an API and database to your Nuxt App with Prisma
schema.prisma datasource db { provider = "sqlite" url = "file:. ... Prisma Client is an auto-generated and type-safe query builder tailored ...
Read more >How to Get Started with Prisma ORM for Node.js and ...
Another con of using an ORM is that the query builder can't do some ... datasource db { provider = "postgresql" url =...
Read more >@prisma/client 2.11.0 on Node.js Yarn - NewReleases.io
generator client { provider = "prisma-client-js" previewFeatures = ["nativeTypes"] } datasource db { provider = "postgresql" url = env("DATABASE_URL") } ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is fixed an will be in the 2.11 release.
@DustinJSilk We are aware of this problem and we intent to tackle it in this sprint(bi weekly release schedule).
There are lot of pending issues so I wouldn’t guarantee it will 100% make it in the next release but we are aware that this is pain point.