From f3401eb671378c72027bd4691f43119bd6082ef2 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Wed, 19 Jul 2023 14:29:21 +1000 Subject: [PATCH] fix(config): export convertNamedPlaceholders parseArguments relied on options.namedPlaceholders, which is now always false. Function is now exported directly when enabled (+typed). --- src/config.ts | 4 +++- src/utils/parseArguments.ts | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index 7bf0b74..cdb7cd5 100644 --- a/src/config.ts +++ b/src/config.ts @@ -61,6 +61,8 @@ const parseUri = (connectionString: string) => { return options; }; +export let convertNamedPlaceholders: null | ((query: string, parameters: Record) => [string, any[]]); + export const connectionOptions = (() => { const options: Record = mysql_connection_string.includes('mysql://') ? parseUri(mysql_connection_string) @@ -76,7 +78,7 @@ export const connectionOptions = (() => { return connectionInfo; }, {}); - options.namedPlaceholders = options.namedPlaceholders === 'false' ? false : true; + convertNamedPlaceholders = options.namedPlaceholders === 'false' ? null : require('named-placeholders')(); for (const key in ['dateStrings', 'flags', 'ssl']) { const value = options[key]; diff --git a/src/utils/parseArguments.ts b/src/utils/parseArguments.ts index 736e6fe..ce07476 100644 --- a/src/utils/parseArguments.ts +++ b/src/utils/parseArguments.ts @@ -1,7 +1,5 @@ import type { CFXCallback, CFXParameters } from '../types'; -import { connectionOptions } from '../config'; - -const convertNamedPlaceholders = connectionOptions.namedPlaceholders && require('named-placeholders')(); +import { convertNamedPlaceholders } from '../config'; export const parseArguments = ( invokingResource: string,