Right now we are able to have empty values in the datasource url(either by hard coding or by environment variable) which cause a runtime error when we try to execute the client.
Schema:
generator photon {
provider = "photonjs"
}
datasource db {
provider = "postgresql"
url = ""
}
model User {
id String @default(cuid()) @id
email String @unique
name String?
posts Post[]
}
model Post {
id String @default(cuid()) @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
published Boolean @default(true)
title String
content String?
author User?
}
Error:

Refer: https://github.com/prisma/photonjs/issues/305#issuecomment-559559485
What would correct or expected behaviour be in this case @pantharshit00?
This probably should be disallowed, it should return a clear error that you have to specify a datasource URL. Related: https://github.com/prisma-labs/nexus-prisma/issues/546#issuecomment-561808751
Thank you @steebchen
@janpio and @pantharshit00 please also have a look at this comment https://github.com/prisma-labs/nexus-prisma/issues/546#issuecomment-561834082
This probably should be disallowed, it should return a clear error that you have to specify a datasource URL. Related: prisma-labs/nexus-prisma#546 (comment)
Either that should be the case or we could use the defaults for example postgresql://localhost:5432/postgres?schema=public is used by many clients as the default value.
This probably should be disallowed, it should return a clear error that you have to specify a datasource URL. Related: prisma-labs/nexus-prisma#546 (comment)
Either that should be the case or we could use the defaults for example
postgresql://localhost:5432/postgres?schema=publicis used by many clients as the default value.
In my opinion this should be a hard error. Then you can't forget to set the connection string when switching environments.
@sorenbs You're assigned to make a product decision here. For me, it's clear that an empty value should be disallowed, especially because it will result in unclear errors. If we ever have default connection string values, we can re-open for discussion, but for now I think this should be disallowed.
The related issue in specs: https://github.com/prisma/specs/issues/365
There's also an issue how this behaves with empty environment values, but that's a different discussion.
A decision has been made by @sorenbs: Just disallow it
Next steps:
This has two aspects wrt the errors spec:
Static empty value: this should be disallowed by the schema parser and would be covered via https://github.com/prisma/prisma-engines/blob/master/libs/user-facing-errors/src/common.rs#L180-L184
Depending on what the default error from schema parser is, we might want to handle this separately but I think SchemaParserError (P1012) should suffice.
Dynamic empty value: this can be set via an environment variable, in this case schema parser and prisma2 generate command cannot know that the value is empty and the earliest point where the value is resolved is Prisma client's constructor. At that point it can fail with an error citing fulfillment of the specific env var (related issue https://github.com/prisma/specs/issues/369).



Most helpful comment
In my opinion this should be a hard error. Then you can't forget to set the connection string when switching environments.