Browse Source

Merge pull request #5288 from Budibase/fix/5187-number

Fix for MySQL number parsing issue
master
Michael Drury 5 years ago
committed by GitHub
parent
commit
3c6a6f8e66
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/server/src/integrations/mysql.ts
  2. 2
      packages/server/src/utilities/index.js

3
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)

2
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) {

Loading…
Cancel
Save