Repository navigation
feat(client): disallow explicit undefined value for adapter - #21315
Merged
millsp merged 2 commits intoOct 3, 2023
Merged
Conversation
Throw on explicit `undefined` value of `adapter` (but not on missing property) and allow `null` to conditionally or explicitly disable driver adapters, as suggested in <#21163 (comment)>. Closes prisma/team-orm#388
aqrln
requested review from
Druue,
Jolg42 and
millsp
and removed request for
a team
October 2, 2023 22:47
Contributor
size-limit report 📦
|
millsp
approved these changes
Oct 2, 2023
millsp
deleted the
feat-client-disallow-explicit-undefined-value-for-adapter
branch
October 3, 2023 00:13
Jolg42
reviewed
Oct 4, 2023
| } | ||
| if (adapter === undefined) { | ||
| throw new PrismaClientConstructorValidationError( | ||
| `"adapter" property must not be undefined, use null to conditionally disable driver adapters.`, |
Contributor
There was a problem hiding this comment.
Additionally, we could also mention: Or remove the driverAdapters preview feature flag?
Contributor
There was a problem hiding this comment.
(though that would not be an option once it's GA)
Member
Author
There was a problem hiding this comment.
Without the feature flag though it would be an unknown option.
steebchen
pushed a commit
to prisma-client-go/prisma
that referenced
this pull request
Oct 4, 2023
aqrln
added a commit
that referenced
this pull request
Nov 3, 2025
This PR introduces a new way to configure the Accelerate URL in
preparation to removing `url` from PSL:
```ts
new PrismaClient({
accelerateUrl: "prisma://...",
})
```
This property is mutually exclusive with `adapter`, and exactly one of
them needs to be provided when using `engineType = "client"`.
It also makes a few related changes along the way or as a side effect:
- Contributes towards
[TML-1459](https://linear.app/prisma-company/issue/TML-1459/remove-processenv-loading-from-prisma-cli-and-prismaclient):
the logic related to environment variables was completely removed from
the `RemoteExecutor` code path, along with the `resolveDatasourceUrl`
function.
- Fixes the `@prisma/extension-accelerate` extension which was
inadvertently broken in #28345:
while most of `accelerateUtils` (which were meant to be used by the
removed `AccelerateEngine`) were indeed never used, one specific method
is actually currently used:
`_accelerateEngineConfig.accelerateUtils.resolveDatasourceUrl`. This PR
now restores this function and re-implements it in a different way.
- As a result of this, we now have a new validation and a DX improvement
we didn't use to: now if you apply the Accelerate extension to a client
that's not actually configured to use Accelerate, you will get a very
clear error with a code suggestion.
- Removes `null` support for the `adapter` constructor option, which was
introduced in #21315. It was the
only option that required `null` instead of `undefined` to disable it
explicitly and it was inconsistent with the others. The [motivation for
introducing `null` and making it different from
`undefined`](#21163 (comment))
made total sense for the `LibraryEngine` (where accidentally setting the
`adapter` to `undefined` meant silently using completely different
drivers before that change) but is now obsolete for the `ClientEngine`.
Since we are removing `LibraryEngine` in
#28375, we don't need this
distinction anymore since there are no longer any pitfalls from using
`adapter: undefined`, and removing it here in this PR made the
validation around the combinations of `adapter` and `accelerateUrl`
easier.
- Fixed the incorrect error message when Accelerate URL cannot be
parsed.
Closes:
https://linear.app/prisma-company/issue/TML-1507/env-less-accelerate-url-configuration
aqrln
added a commit
that referenced
this pull request
Nov 17, 2025
This PR introduces a new way to configure the Accelerate URL in
preparation to removing `url` from PSL:
```ts
new PrismaClient({
accelerateUrl: "prisma://...",
})
```
This property is mutually exclusive with `adapter`, and exactly one of
them needs to be provided when using `engineType = "client"`.
It also makes a few related changes along the way or as a side effect:
- Contributes towards
[TML-1459](https://linear.app/prisma-company/issue/TML-1459/remove-processenv-loading-from-prisma-cli-and-prismaclient):
the logic related to environment variables was completely removed from
the `RemoteExecutor` code path, along with the `resolveDatasourceUrl`
function.
- Fixes the `@prisma/extension-accelerate` extension which was
inadvertently broken in #28345:
while most of `accelerateUtils` (which were meant to be used by the
removed `AccelerateEngine`) were indeed never used, one specific method
is actually currently used:
`_accelerateEngineConfig.accelerateUtils.resolveDatasourceUrl`. This PR
now restores this function and re-implements it in a different way.
- As a result of this, we now have a new validation and a DX improvement
we didn't use to: now if you apply the Accelerate extension to a client
that's not actually configured to use Accelerate, you will get a very
clear error with a code suggestion.
- Removes `null` support for the `adapter` constructor option, which was
introduced in #21315. It was the
only option that required `null` instead of `undefined` to disable it
explicitly and it was inconsistent with the others. The [motivation for
introducing `null` and making it different from
`undefined`](#21163 (comment))
made total sense for the `LibraryEngine` (where accidentally setting the
`adapter` to `undefined` meant silently using completely different
drivers before that change) but is now obsolete for the `ClientEngine`.
Since we are removing `LibraryEngine` in
#28375, we don't need this
distinction anymore since there are no longer any pitfalls from using
`adapter: undefined`, and removing it here in this PR made the
validation around the combinations of `adapter` and `accelerateUrl`
easier.
- Fixed the incorrect error message when Accelerate URL cannot be
parsed.
Closes:
https://linear.app/prisma-company/issue/TML-1507/env-less-accelerate-url-configuration
aqrln
added a commit
that referenced
this pull request
Nov 17, 2025
This PR introduces a new way to configure the Accelerate URL in
preparation to removing `url` from PSL:
```ts
new PrismaClient({
accelerateUrl: "prisma://...",
})
```
This property is mutually exclusive with `adapter`, and exactly one of
them needs to be provided when using `engineType = "client"`.
It also makes a few related changes along the way or as a side effect:
- Contributes towards
[TML-1459](https://linear.app/prisma-company/issue/TML-1459/remove-processenv-loading-from-prisma-cli-and-prismaclient):
the logic related to environment variables was completely removed from
the `RemoteExecutor` code path, along with the `resolveDatasourceUrl`
function.
- Fixes the `@prisma/extension-accelerate` extension which was
inadvertently broken in #28345:
while most of `accelerateUtils` (which were meant to be used by the
removed `AccelerateEngine`) were indeed never used, one specific method
is actually currently used:
`_accelerateEngineConfig.accelerateUtils.resolveDatasourceUrl`. This PR
now restores this function and re-implements it in a different way.
- As a result of this, we now have a new validation and a DX improvement
we didn't use to: now if you apply the Accelerate extension to a client
that's not actually configured to use Accelerate, you will get a very
clear error with a code suggestion.
- Removes `null` support for the `adapter` constructor option, which was
introduced in #21315. It was the
only option that required `null` instead of `undefined` to disable it
explicitly and it was inconsistent with the others. The [motivation for
introducing `null` and making it different from
`undefined`](#21163 (comment))
made total sense for the `LibraryEngine` (where accidentally setting the
`adapter` to `undefined` meant silently using completely different
drivers before that change) but is now obsolete for the `ClientEngine`.
Since we are removing `LibraryEngine` in
#28375, we don't need this
distinction anymore since there are no longer any pitfalls from using
`adapter: undefined`, and removing it here in this PR made the
validation around the combinations of `adapter` and `accelerateUrl`
easier.
- Fixed the incorrect error message when Accelerate URL cannot be
parsed.
Closes:
https://linear.app/prisma-company/issue/TML-1507/env-less-accelerate-url-configuration
aqrln
added a commit
that referenced
this pull request
Nov 17, 2025
This PR introduces a new way to configure the Accelerate URL in
preparation to removing `url` from PSL:
```ts
new PrismaClient({
accelerateUrl: "prisma://...",
})
```
This property is mutually exclusive with `adapter`, and exactly one of
them needs to be provided when using `engineType = "client"`.
It also makes a few related changes along the way or as a side effect:
- Contributes towards
[TML-1459](https://linear.app/prisma-company/issue/TML-1459/remove-processenv-loading-from-prisma-cli-and-prismaclient):
the logic related to environment variables was completely removed from
the `RemoteExecutor` code path, along with the `resolveDatasourceUrl`
function.
- Fixes the `@prisma/extension-accelerate` extension which was
inadvertently broken in #28345:
while most of `accelerateUtils` (which were meant to be used by the
removed `AccelerateEngine`) were indeed never used, one specific method
is actually currently used:
`_accelerateEngineConfig.accelerateUtils.resolveDatasourceUrl`. This PR
now restores this function and re-implements it in a different way.
- As a result of this, we now have a new validation and a DX improvement
we didn't use to: now if you apply the Accelerate extension to a client
that's not actually configured to use Accelerate, you will get a very
clear error with a code suggestion.
- Removes `null` support for the `adapter` constructor option, which was
introduced in #21315. It was the
only option that required `null` instead of `undefined` to disable it
explicitly and it was inconsistent with the others. The [motivation for
introducing `null` and making it different from
`undefined`](#21163 (comment))
made total sense for the `LibraryEngine` (where accidentally setting the
`adapter` to `undefined` meant silently using completely different
drivers before that change) but is now obsolete for the `ClientEngine`.
Since we are removing `LibraryEngine` in
#28375, we don't need this
distinction anymore since there are no longer any pitfalls from using
`adapter: undefined`, and removing it here in this PR made the
validation around the combinations of `adapter` and `accelerateUrl`
easier.
- Fixed the incorrect error message when Accelerate URL cannot be
parsed.
Closes:
https://linear.app/prisma-company/issue/TML-1507/env-less-accelerate-url-configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Throw on explicit
undefinedvalue ofadapter(but not on missingproperty) and allow
nullto conditionally or explicitly disable driveradapters, as suggested in #21163 (comment).
Closes https://github.com/prisma/team-orm/issues/388