From 94fe76340ef9e5e609089c9eac287074e72c3de6 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 2 Dec 2021 19:32:38 +1100 Subject: [PATCH] fix: undefined values Various mistakes from 1.8.1 --- lua/fxmanifest.lua | 2 +- src/execute.js | 2 +- src/index.js | 3 ++- src/pool.js | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/fxmanifest.lua b/lua/fxmanifest.lua index 8b874ca..b49abd7 100644 --- a/lua/fxmanifest.lua +++ b/lua/fxmanifest.lua @@ -3,7 +3,7 @@ game 'common' name 'oxmysql' description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.' -version '1.8.2' +version '1.8.3' url 'https://github.com/overextended/oxmysql' author 'overextended' use_fxv2_oal 'yes' diff --git a/src/execute.js b/src/execute.js index 8abeda8..821d17d 100644 --- a/src/execute.js +++ b/src/execute.js @@ -71,7 +71,7 @@ const preparedStatement = async (query, parameters, resource) => { const executionTime = process.hrtime(startTime)[1] / 1000000; // nanosecond to millisecond if (executionTime >= slowQueryWarning || debug) console.log( - `^3[${debug ? 'DEBUG' : 'WARNING'}] ${resource} took ${totalTime}ms to execute ${ + `^3[${debug ? 'DEBUG' : 'WARNING'}] ${resource} took ${executionTime}ms to execute ${ queryCount > 1 ? queryCount + ' queries' : 'a query' }! ${query} ${JSON.stringify(parameters)}^0` diff --git a/src/index.js b/src/index.js index ad6d607..892d835 100644 --- a/src/index.js +++ b/src/index.js @@ -52,7 +52,8 @@ global.exports('prepare', (query, parameters, cb, resource = GetInvokingResource preparedStatement(query, parameters, resource).then((result) => safeCallback(cb || parameters, result)); }); -if (GetEntityAttachedTo || !GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) { +// Check for a recent native (~server artifact 4700) to enable JS exports +if (GetEntityAttachedTo !== undefined || !GetResourceMetadata(GetCurrentResourceName(), 'server_script', 1)) { global.exports('prepareSync', async (query, parameters) => { const result = await preparedStatement(query, parameters, GetInvokingResource()); return result; diff --git a/src/pool.js b/src/pool.js index 484baaa..0695c36 100644 --- a/src/pool.js +++ b/src/pool.js @@ -10,7 +10,7 @@ if (connectionString === '') { const dbOptions = (() => { const options = connectionString.includes('mysql://') ? { uri: connectionString } - : (options = connectionString + : connectionString .replace(/(?:host(?:name)|ip|server|data\s?source|addr(?:ess)?)=/gi, 'host=') .replace(/(?:user\s?(?:id|name)?|uid)=/gi, 'user=') .replace(/(?:pwd|pass)=/gi, 'password=') @@ -20,7 +20,7 @@ const dbOptions = (() => { const [key, value] = parameter.split('='); connectionInfo[key] = value; return connectionInfo; - }, {})); + }, {}); options.namedPlaceholders = true; options.typeCast = parseTypes;