mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 22:20:56 +00:00
tweak(utils): check if namedPlaceholders are enabled
Named placeholders were being converted regardless of config flag.
This commit is contained in:
1 parent
521aa8f03d
commit
71c32f9d2f
1 file changed
+11
-9
@@ -1,6 +1,7 @@
|
|||||||
import type { CFXCallback, CFXParameters } from '../types';
|
import type { CFXCallback, CFXParameters } from '../types';
|
||||||
|
import { connectionOptions } from '../config';
|
||||||
|
|
||||||
const convertNamedPlaceholders = require('named-placeholders')();
|
const convertNamedPlaceholders = connectionOptions.namedPlaceholders && require('named-placeholders')();
|
||||||
|
|
||||||
export const parseArguments = (
|
export const parseArguments = (
|
||||||
invokingResource: string,
|
invokingResource: string,
|
||||||
@@ -10,14 +11,15 @@ export const parseArguments = (
|
|||||||
): [string, CFXParameters, CFXCallback | undefined] => {
|
): [string, CFXParameters, CFXCallback | undefined] => {
|
||||||
if (typeof query !== 'string') throw new Error(`Query expected a string but received ${typeof query} instead`);
|
if (typeof query !== 'string') throw new Error(`Query expected a string but received ${typeof query} instead`);
|
||||||
|
|
||||||
if (
|
if (convertNamedPlaceholders)
|
||||||
(query.includes(':') && parameters && typeof parameters === 'object' && !Array.isArray(parameters)) ||
|
if (
|
||||||
query.includes('@')
|
(query.includes(':') && parameters && typeof parameters === 'object' && !Array.isArray(parameters)) ||
|
||||||
) {
|
query.includes('@')
|
||||||
const placeholders = convertNamedPlaceholders(query, parameters);
|
) {
|
||||||
query = placeholders[0];
|
const placeholders = convertNamedPlaceholders(query, parameters);
|
||||||
parameters = placeholders[1];
|
query = placeholders[0];
|
||||||
}
|
parameters = placeholders[1];
|
||||||
|
}
|
||||||
|
|
||||||
if (cb && typeof cb !== 'function') cb = undefined;
|
if (cb && typeof cb !== 'function') cb = undefined;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user