From c4a42cc1811a6b22473e18ef3b81ab10e0367699 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 7 Apr 2022 10:26:39 +0100 Subject: [PATCH] Fix for issue discovered in #5187 - expanding regex to cover all sorts of number coercion. --- packages/server/src/integrations/mysql.ts | 3 ++- packages/server/src/utilities/index.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/integrations/mysql.ts b/packages/server/src/integrations/mysql.ts index cd5dc77f9b..6efcdf53de 100644 --- a/packages/server/src/integrations/mysql.ts +++ b/packages/server/src/integrations/mysql.ts @@ -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) diff --git a/packages/server/src/utilities/index.js b/packages/server/src/utilities/index.js index 221c2ff18b..66005fd9cd 100644 --- a/packages/server/src/utilities/index.js +++ b/packages/server/src/utilities/index.js @@ -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) {