Compare commits

...
6 Commits
Author SHA1 Message Date
Linden abf259543d chore: Update version and dependencies 2021-10-18 02:19:09 +11:00
Linden 9d8a29388c fix(parser): Only assign null values if placeholders were found 2021-10-18 01:52:22 +11:00
Linden 00f9d0449c fix(regex): Prevent converting JSON in queries into placeholders
- When a JSON string is entered as part of a query, rather than a parameter, it is assumed to define a named placeholder - this will check for quotations and ignore it
2021-10-18 01:51:37 +11:00
Linden a46b586832 Merge pull request #51 from darksaid98/main
fix(parse): Resolve nil parameters when using `['@key'] = val`
2021-10-17 04:16:04 +11:00
darksaid98 dc50fe6dbb style: rename paramName variable 2021-10-16 19:11:09 +02:00
darksaid98 a6d483ca48 fix: nil parameters with named placeholders
- Fixes the remaining edge-case bug with passing nil parameters
2021-10-16 19:05:57 +02:00
5 changed files with 28 additions and 13 deletions

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ game 'common'
name 'oxmysql'
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
version '1.6.1'
version '1.6.2'
url 'https://github.com/overextended/oxmysql'
author 'overextended'
use_fxv2_oal 'yes'
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "oxmysql",
"version": "1.6.1",
"version": "1.6.2",
"main": "oxmysql.js",
"description": "node-mysql2 resource for Cfx",
"repository": "[email protected]:overextended/oxmysql.git",
+2 -2
View File
@@ -1,5 +1,5 @@
diff --git a/node_modules/named-placeholders/index.js b/node_modules/named-placeholders/index.js
index 527d723..1ac61d5 100644
index 527d723..f63ce28 100644
--- a/node_modules/named-placeholders/index.js
+++ b/node_modules/named-placeholders/index.js
@@ -3,7 +3,7 @@
@@ -7,7 +7,7 @@ index 527d723..1ac61d5 100644
// License: https://github.com/mscdex/node-mariasql/blob/master/LICENSE
-const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_]*)))/g,
+const RE_PARAM = /(?:\?)|(?:[:@](\d+|(?:[a-zA-Z][a-zA-Z0-9_]*)))/g,
+const RE_PARAM = /(?:\?)|(?:(?<!["'])[:@](\d+|(?:[a-zA-Z][a-zA-Z0-9_]*)))/g,
DQUOTE = 34,
SQUOTE = 39,
BSLASH = 92;
+16 -1
View File
@@ -1,4 +1,7 @@
import { FormatError } from './errors';
import * as createCompiler from 'named-placeholders';
const convertNamedPlaceholders = createCompiler();
const parseTypes = (field, next) => {
//https://github.com/GHMatti/ghmattimysql/blob/37f1d2ae5c53f91782d168fe81fba80512d3c46d/packages/ghmattimysql/src/server/utility/typeCast.ts#L3
@@ -27,7 +30,19 @@ const parseParameters = (query, parameters) => {
if (typeof parameters === 'function') return [query, []];
if (query.includes('@') || query.includes(':')) return [query, parameters];
if (query.includes('@') || query.includes(':')) {
const obj = parameters.length !== 0 ? parameters : (() => {
let obj = {};
const [_, paramNames] = convertNamedPlaceholders.parse(query);
if (paramNames) {
for (let i = 0; i < paramNames.length; i++)
obj[paramNames[i]] = null;
}
return obj;
})();
return [query, obj]
};
const queryParams = query.match(/\?(?!\?)/g);
+8 -8
View File
@@ -60,9 +60,9 @@
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
"@types/node@*":
version "16.11.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.0.tgz#4b95f2327bacd1ef8f08d8ceda193039c5d7f52e"
integrity sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==
version "16.11.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.1.tgz#2e50a649a50fc403433a14f829eface1a3443e97"
integrity sha512-PYGcJHL9mwl1Ek3PLiYgyEKtwTMmkMw4vbiyz/ps3pfdRYLVv+SN7qHVAImrjdAXxgluDEw6Ph4lyv+m9UpRmA==
"@webassemblyjs/[email protected]":
version "1.11.1"
@@ -291,9 +291,9 @@ buffer-from@^1.0.0:
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
caniuse-lite@^1.0.30001265:
version "1.0.30001267"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001267.tgz#b1cf2937175afc0570e4615fc2d2f9069fa0ed30"
integrity sha512-r1mjTzAuJ9W8cPBGbbus8E0SKcUP7gn03R14Wk8FlAlqhH9hroy9nLqmpuXlfKEw/oILW+FGz47ipXV2O7x8lg==
version "1.0.30001269"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001269.tgz#3a71bee03df627364418f9fd31adfc7aa1cc2d56"
integrity sha512-UOy8okEVs48MyHYgV+RdW1Oiudl1H6KolybD6ZquD0VcrPSgj25omXO1S7rDydjpqaISCwA8Pyx+jUQKZwWO5w==
chalk@^2.4.2:
version "2.4.2"
@@ -880,8 +880,8 @@ minimist@^1.2.0:
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
"mysql2@https://github.com/overextended/node-mysql2.git":
version "2.3.0"
resolved "https://github.com/overextended/node-mysql2.git#0bd156905d3093d33dddbde10adf1ca8ede18680"
version "2.3.2"
resolved "https://github.com/overextended/node-mysql2.git#60c66356b36d1dd194de6b1bc52d4216ee6f92d3"
dependencies:
denque "^2.0.1"
generate-function "^2.3.1"