Fix for issue discovered in #5187 - expanding regex to cover all sorts of number coercion.

This commit is contained in:
mike12345567 2022-04-07 10:26:39 +01:00
parent 4e65e994b9
commit c4a42cc181
2 changed files with 4 additions and 1 deletions

View File

@ -15,6 +15,7 @@ import {
} from "./utils"
import { DatasourcePlus } from "./base/datasourcePlus"
import dayjs from "dayjs"
const { NUMBER_REGEX } = require("../utilities")
module MySQLModule {
const mysql = require("mysql2/promise")
@ -87,7 +88,7 @@ module MySQLModule {
if (typeof binding !== "string") {
continue
}
const matches = binding.match(/^\d*$/g)
const matches = binding.match(NUMBER_REGEX)
// check if number first
if (matches && matches[0] !== "" && !isNaN(Number(matches[0]))) {
bindings[i] = parseFloat(binding)

View File

@ -11,6 +11,8 @@ exports.wait = ms => new Promise(resolve => setTimeout(resolve, ms))
exports.isDev = env.isDev
exports.NUMBER_REGEX = /^[+-]?([0-9]*[.])?[0-9]+$/g
exports.removeFromArray = (array, element) => {
const index = array.indexOf(element)
if (index !== -1) {