@@ -15,6 +15,7 @@ import { tracer } from '~/tracing.ts';
1515import { type Assume , mapResultRow } from '~/utils.ts' ;
1616
1717const { Pool, types} = pg ;
18+ const NativePool = ( < any > pg ) . native ?( < { Pool :typeof Pool } > ( < any > pg ) . native ) . Pool :undefined ;
1819
1920export type NodePgClient = pg . Pool | PoolClient | Client ;
2021
@@ -249,7 +250,7 @@ export class NodePgSession<
249250transaction :( tx :NodePgTransaction < TFullSchema , TSchema > ) => Promise < T > ,
250251config ?:PgTransactionConfig | undefined ,
251252) :Promise < T > {
252- const session = this . client instanceof Pool // eslint-disable-line no-instanceof/no-instanceof
253+ const session = ( this . client instanceof Pool || ( NativePool && this . client instanceof NativePool ) ) // eslint-disable-line no-instanceof/no-instanceof
253254?new NodePgSession ( await this . client . connect ( ) , this . dialect , this . schema , this . options )
254255:this ;
255256const tx = new NodePgTransaction < TFullSchema , TSchema > ( this . dialect , session , this . schema ) ;
@@ -262,7 +263,7 @@ export class NodePgSession<
262263await tx . execute ( sql `rollback` ) ;
263264throw error ;
264265} finally {
265- if ( this . client instanceof Pool ) { // eslint-disable-line no-instanceof/no-instanceof
266+ if ( this . client instanceof Pool || ( NativePool && this . client instanceof NativePool ) ) { // eslint-disable-line no-instanceof/no-instanceof
266267( session . client as PoolClient ) . release ( ) ;
267268}
268269}