File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -189,8 +189,12 @@ export const createPostgresBridge = (postgres: typeof Postgres) => {
189189 rows : Array . from ( resultArray ) ,
190190 } ;
191191 } ,
192- release : async ( ) => {
193- await this . pool . release ( compatibleConnection ) ;
192+ release : async ( remove : boolean = false ) => {
193+ if ( remove ) {
194+ await this . pool . destroy ( compatibleConnection ) ;
195+ } else {
196+ await this . pool . release ( compatibleConnection ) ;
197+ }
194198 } ,
195199 } ;
196200
Original file line number Diff line number Diff line change @@ -191,6 +191,20 @@ for (const {
191191 t . is ( pool . idleCount , 1 ) ;
192192 } ) ;
193193
194+ test ( clientName + ': connection.release(true) removes connection from the pool' , async ( t ) => {
195+ const pool = new Pool ( {
196+ user : 'postgres' ,
197+ } ) ;
198+
199+ const connection = await pool . connect ( ) ;
200+
201+ t . is ( pool . totalCount , 1 ) ;
202+
203+ await connection . release ( true ) ;
204+
205+ t . is ( pool . totalCount , 0 ) ;
206+ } ) ;
207+
194208 test ( clientName + ': connection.query() returns integers' , async ( t ) => {
195209 const pool = new Pool ( {
196210 user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments