From 0600829b7016285e9a7e8db2dccd44f516c669ec Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sun, 17 Dec 2023 11:59:36 +0800 Subject: [PATCH] Allow connectionString and options Currently there is no way for the user to specify for example `typeCast` if we are using a connection string. This makes it possible to specify a `connectionString` option and then override options if needed --- lib/ConnectionConfig.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ConnectionConfig.js b/lib/ConnectionConfig.js index 06f4399c5..66b6bb574 100644 --- a/lib/ConnectionConfig.js +++ b/lib/ConnectionConfig.js @@ -9,6 +9,10 @@ function ConnectionConfig(options) { options = ConnectionConfig.parseUrl(options); } + if (typeof options.connectionString === 'string') { + options = { ...ConnectionConfig.parseUrl(options.connectionString), ...options }; + } + this.host = options.host || 'localhost'; this.port = options.port || 3306; this.localAddress = options.localAddress;