Skip to content

Commit

Permalink
fix: undefined values
Browse files Browse the repository at this point in the history
Various mistakes from 1.8.1
  • Loading branch information
thelindat committed Dec 2, 2021
1 parent b776314 commit 94fe763
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lua/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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=')
Expand All @@ -20,7 +20,7 @@ const dbOptions = (() => {
const [key, value] = parameter.split('=');
connectionInfo[key] = value;
return connectionInfo;
}, {}));
}, {});

options.namedPlaceholders = true;
options.typeCast = parseTypes;
Expand Down

0 comments on commit 94fe763

Please sign in to comment.