From 2a18967418ae9ba0e3c36a68fd41033dfd292544 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 17 Aug 2022 23:11:56 +0800 Subject: [PATCH] fix: db version check (#749) resolve #742 --- packages/core/database/src/database.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index c035937e4..bccbdb53c 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -81,14 +81,16 @@ class DatabaseVersion { }, mysql: { sql: 'select version() as version', - get: (v) => v, + get: (v) => { + const m = /([\d+\.]+)/.exec(v); + return m[0]; + }, }, postgres: { sql: 'select version() as version', get: (v) => { - const keys = v.split(/\s|,/); - keys.shift(); - return semver.minVersion(keys.shift()).version; + const m = /([\d+\.]+)/.exec(v); + return semver.minVersion(m[0]).version; }, }, };