From b604a3c35666970d9bca0ef14678c88e3c8b2f7f Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Wed, 21 Sep 2022 14:10:23 +1000 Subject: [PATCH] fix(src/config): parse JSON objects in connection string Some connection properties take an object/array (i.e. ssl, flags). --- src/config/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/config/index.ts b/src/config/index.ts index b9f88a6..4a66c4e 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -72,6 +72,17 @@ export const connectionOptions = (() => { options.namedPlaceholders = options.namedPlaceholders === 'false' ? false : true; + for (const key in options) { + const value = options[key]; + + if (typeof value === 'string') { + try { + options[key] = JSON.parse(value); + console.log(key, options[key]); + } catch {} + } + } + return options; })();