You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ability to pass driver instance for Prisma Driver Adapters as before v6.6.0 #26885
I would like to ask you to add the ability to pass DB driver instance into Prisma Driver Adapters as it was before Prisma v6.6.0, additionally to the current ability to pass driver options only.
Use Cases & Problem Description
It was very useful, it allowed to make an instance of DB connection pool with a DB driver outside of Prisma Adapter, and share the connection pool between Prisma and some third-party query builder to be able to write queries, that Prisma itself writes not very optimissed
Proposed Solution
Just use the previous interface, that was before the v6.6.0 so user can pass either a driver instance declared outside of the Prisma Adapter, or pass the driver options as in v6.6.0
Alternative Solutions
N/A
Potential Considerations
No response
Prisma Version
6.6.0
What part of Prisma does this affect?
Prisma Client
Additional Context
No response
Pre-Submission Checklist
I have searched existing issues to make sure this is not a duplicate
I have checked the Prisma roadmap to see if this is already planned
I have described why this belongs in Prisma Core rather than a solution in application code
Reacted by Adrien, Michael Nahkies, tjhiggins, Tommy D. Rossi, Erwin Dee Villejo, AlexCaston, Daniel Mateos Labrador, iamciroja, jordanveitia-storyteq, Sam Lewis and 5 more
Initially felt affected by this change as well, given that we use the pg Adapter to handle Managed Identity Authentication with Microsoft Azure (see Medium Article) when running in prod and otherwise falling back to a connection string in dev.
After a closer evaluation we were able to tweak our code to migrate to the new path for those adapters.
We used this in our codebase (now removed as this was a leftover, unwanted log collected):
Possible use case for this feature (at least for pg-Adapter) would be to respond to lifecycle events by the Pool instance passed (as seen here). Especially addding a listener to the error event is heavily encouraged by pg to prevent crashing the entire node process on error! (see the Callout in the linked documentation).
For fellow devs, the error Argument of type 'Pool' is not assignable to parameter of type 'PoolConfig'. is caused by Prisma v6.6.0 and requires you to pass the instantiating options (new Pool{options}) into new PrismaPg({options}).
In my opinion this change should be considered breaking (especially lacking legacy support for previous instantiation) and be highlighted as such.
I'd like to list another use-case: now that metrics preview feature is deprecated, we need a direct access to the driver adapter in order to see pool.waitingCount, pool.idleCount etc. to monitor the utilization.
For anyone having the same need, I've found a way to access the adapter instance:
Activity
TimLinsenmayer commentedon Apr 13, 2025
Initially felt affected by this change as well, given that we use the pg Adapter to handle Managed Identity Authentication with Microsoft Azure (see Medium Article) when running in prod and otherwise falling back to a connection string in dev.
After a closer evaluation we were able to tweak our code to migrate to the new path for those adapters.
We used this in our codebase (now removed as this was a leftover, unwanted log collected):
Possible use case for this feature (at least for pg-Adapter) would be to respond to lifecycle events by the Pool instance passed (as seen here). Especially addding a listener to the error event is heavily encouraged by pg to prevent crashing the entire node process on error! (see the Callout in the linked documentation).
For fellow devs, the error
Argument of type 'Pool' is not assignable to parameter of type 'PoolConfig'.is caused by Prisma v6.6.0 and requires you to pass the instantiating options (new Pool{options}) intonew PrismaPg({options}).In my opinion this change should be considered breaking (especially lacking legacy support for previous instantiation) and be highlighted as such.
feat(pg-adapter): Allow passing Pool instance directly to PgAdapterFa…
feat(adapter-pg): Allow passing Pool instance directly to PgAdapterFa…
erwinv commentedon May 2, 2025
I opened a PR that addresses this for the pg adapter. For those using PNPM, here's the PNPM patch targeting 6.7.0 (the latest version as of writing):
@[email protected]
ialpert commentedon Jun 3, 2025
Relevant PRs:
#27062
#26935
wodCZ commentedon Jun 28, 2025
I'd like to list another use-case: now that metrics preview feature is deprecated, we need a direct access to the driver adapter in order to see
pool.waitingCount,pool.idleCountetc. to monitor the utilization.For anyone having the same need, I've found a way to access the adapter instance:
Obviously, it's dependent on private interface, which can change without notice, so use with caution.
feat(adapter-pg): Allow passing Pool instance directly to PgAdapterFa…
barryhagan commentedon Jul 13, 2025
Another argument for why pg.Pool should not be completely internal: #27641
feat(adapter-pg): Allow passing Pool instance directly to PgAdapterFa…
feat(adapter-mariadb): support passing a pool instance (#27992)
feat(adapter-mariadb): support passing a pool instance (prisma#27992)