Repository navigation
Description
What problem are you trying to solve?
@prisma/adapter-pg currently type-checks and validates the pool passed into PrismaPg against its own bundled pg.Pool class (type StdClient = pg.Pool in pg.ts). This means any drop-in-compatible fork of pg — for example YugabyteDB's smart driver (@yugabytedb/pg), which extends pg to add cluster-topology-aware load balancing and failover — fails to work with Prisma, even though it implements the same interface and is designed as a compatible replacement.
Problem:
Other ORMs (TypeORM, Sequelize, Drizzle) support these forks transparently via simple package aliasing ("pg": "npm:@yugabytedb/pg" in package.json), because they consume pg structurally rather than checking identity against a specific bundled class. @prisma/adapter-pg cannot do this today because it depends on its own internal copy of pg, and its Pool validation is tied to that exact class reference.
Impact:
Without this, Prisma users on distributed Postgres-compatible databases like YugabyteDB (or CockroachDB, or any future fork with similar smart-driver patterns) can't get automatic node-discovery/failover from the driver layer. The only workaround is standing up an external load balancer (e.g. HAProxy) in front of the cluster, purely to compensate for something the driver could otherwise do natively.
Request:
Could @prisma/adapter-pg validate the passed pool structurally (duck-typing against the required methods: .query(), .connect(), .end(), etc.) instead of via instanceof against its own bundled pg.Pool? This would let compatible forks work without requiring Prisma to explicitly support each one.
Happy to provide a minimal repro if useful.
Proposed solution
Proposed solution
Instead of relying on instanceof pg.Pool (which only matches the exact bundled class), validate the passed object structurally — check that it exposes the methods @prisma/adapter-pg actually uses (query, connect, end, and whatever else the adapter calls internally), similar to duck-typing:
function isPgPoolLike(obj: unknown): obj is StdClient {
return (
!!obj &&
typeof (obj as any).query === 'function' &&
typeof (obj as any).connect === 'function' &&
typeof (obj as any).end === 'function'
);
}
This would accept any object that behaves like a pg.Pool — including forks such as @yugabytedb/pg's BoundPool — without Prisma needing to explicitly special-case each fork.
Alternative, if a structural check is considered too loose: expose an explicit escape hatch, e.g. an unsafeSkipPoolValidation (or similarly named) constructor option on PrismaPg, so users who know they're passing a compatible fork can opt in without Prisma having to guarantee full type safety for every possible pg-compatible driver:
const adapter = new PrismaPg(customPool, { unsafeSkipPoolValidation: true })
Either approach unblocks compatible forks (YugabyteDB smart driver, and potentially others in the future) without requiring Prisma to take on a maintenance burden for each one individually. I'd lean toward the structural check as the cleaner long-term fix, with the escape hatch as a lower-effort stopgap if that's easier to ship first.
Alternatives considered
No response
Scope and impact
No response
Activity
SnowingFox commentedon Aug 10, 2026
Opened a PR to address this: #29956
fix(adapter-pg): accept pg-compatible pool implementations structurally
fix(adapter-pg): accept pg-compatible pool implementations structurally
Mohamed-Sayed-M commentedon Oct 2, 2026
when it will be closed ? i run this issue also . i can see someone has solution but why it did not merge ?
Mohamed-Sayed-M commentedon Oct 2, 2026
does the prisma 8 fix this ?
fix(adapter-pg): accept pg-compatible pool implementations structurally