@@ -36,8 +36,9 @@ export class NodePostgresDriverDialect implements DriverDialect {
36
36
}
37
37
38
38
async connect ( hostInfo : HostInfo , props : Map < string , any > ) : Promise < ClientWrapper > {
39
- this . setKeepAliveProperties ( props ) ;
40
- const targetClient = new pkgPg . Client ( WrapperProperties . removeWrapperProperties ( props ) ) ;
39
+ const driverProperties = WrapperProperties . removeWrapperProperties ( props ) ;
40
+ this . setKeepAliveProperties ( driverProperties , props . get ( WrapperProperties . KEEPALIVE_PROPERTIES . name ) ) ;
41
+ const targetClient = new pkgPg . Client ( driverProperties ) ;
41
42
await targetClient . connect ( ) ;
42
43
return Promise . resolve ( new PgClientWrapper ( targetClient , hostInfo , props ) ) ;
43
44
}
@@ -59,15 +60,19 @@ export class NodePostgresDriverDialect implements DriverDialect {
59
60
return new AwsPgPoolClient ( props ) ;
60
61
}
61
62
62
- setKeepAliveProperties ( props : Map < string , any > ) {
63
- if ( props . has ( WrapperProperties . KEEPALIVE_PROPERTIES . name ) ) {
64
- const keepAliveProps = props . get ( WrapperProperties . KEEPALIVE_PROPERTIES . name ) ;
65
- props . set ( NodePostgresDriverDialect . keepAlivePropertyName , keepAliveProps . get ( NodePostgresDriverDialect . keepAlivePropertyName ) ) ;
66
- props . set (
67
- NodePostgresDriverDialect . keepAliveInitialDelayMillisPropertyName ,
68
- keepAliveProps . get ( NodePostgresDriverDialect . keepAliveInitialDelayMillisPropertyName )
69
- ) ;
70
- props . delete ( WrapperProperties . KEEPALIVE_PROPERTIES . name ) ;
63
+ setKeepAliveProperties ( props : Map < string , any > , keepAliveProps : any ) {
64
+ if ( ! keepAliveProps ) {
65
+ return ;
66
+ }
67
+
68
+ const keepAlive = keepAliveProps . get ( NodePostgresDriverDialect . keepAlivePropertyName ) ;
69
+ const keepAliveInitialDelayMillis = keepAliveProps . get ( NodePostgresDriverDialect . keepAliveInitialDelayMillisPropertyName ) ;
70
+
71
+ if ( keepAlive ) {
72
+ props . set ( NodePostgresDriverDialect . keepAlivePropertyName , keepAlive ) ;
73
+ }
74
+ if ( keepAliveInitialDelayMillis ) {
75
+ props . set ( NodePostgresDriverDialect . keepAliveInitialDelayMillisPropertyName , keepAliveInitialDelayMillis ) ;
71
76
}
72
77
}
73
78
}
0 commit comments