mysql: When configured Pool.config has different structure from what's expected at createPool() (#45860)

* When configured Pool.config has different structure from what's expected at createPool()

* Test added
This commit is contained in:
Andrew Schekatihin 2020-07-12 10:52:09 +03:00 committed by GitHub
parent 7ca8470413
commit 80ddbd163b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -189,7 +189,7 @@ export interface PoolConnection extends Connection {
}
export interface Pool extends EscapeFunctions {
config: PoolConfig;
config: PoolActualConfig;
getConnection(callback: (err: MysqlError, connection: PoolConnection) => void): void;
@ -583,7 +583,7 @@ export interface ConnectionConfig extends ConnectionOptions {
ssl?: string | (tls.SecureContextOptions & { rejectUnauthorized?: boolean });
}
export interface PoolConfig extends ConnectionConfig {
export interface PoolSpecificConfig {
/**
* The milliseconds before a timeout occurs during the connection acquisition. This is slightly different from connectTimeout,
* because acquiring a pool connection does not always involve making a connection. (Default: 10 seconds)
@ -609,6 +609,13 @@ export interface PoolConfig extends ConnectionConfig {
queueLimit?: number;
}
export interface PoolConfig extends PoolSpecificConfig, ConnectionConfig {
}
export interface PoolActualConfig extends PoolSpecificConfig {
connectionConfig: ConnectionConfig;
}
export interface PoolClusterConfig {
/**
* If true, PoolCluster will attempt to reconnect when connection fails. (Default: true)

View File

@ -184,6 +184,8 @@ const poolConfig = {
let pool = mysql.createPool(poolConfig);
console.log('Connection timezone config:', pool.config.connectionConfig.timezone);
pool.query('SELECT 1 + 1 AS solution', (err, rows, fields) => {
if (err) throw err;