File tree 2 files changed +20
-2
lines changed
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) => {
189
189
rows : Array . from ( resultArray ) ,
190
190
} ;
191
191
} ,
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
+ }
194
198
} ,
195
199
} ;
196
200
Original file line number Diff line number Diff line change @@ -191,6 +191,20 @@ for (const {
191
191
t . is ( pool . idleCount , 1 ) ;
192
192
} ) ;
193
193
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
+
194
208
test ( clientName + ': connection.query() returns integers' , async ( t ) => {
195
209
const pool = new Pool ( {
196
210
user : 'postgres' ,
You can’t perform that action at this time.
0 commit comments