fix: db version check (#749)

resolve #742
This commit is contained in:
chenos 2022-08-17 23:11:56 +08:00 committed by GitHub
parent 9b47ba2251
commit 2a18967418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,14 +81,16 @@ class DatabaseVersion {
}, },
mysql: { mysql: {
sql: 'select version() as version', sql: 'select version() as version',
get: (v) => v, get: (v) => {
const m = /([\d+\.]+)/.exec(v);
return m[0];
},
}, },
postgres: { postgres: {
sql: 'select version() as version', sql: 'select version() as version',
get: (v) => { get: (v) => {
const keys = v.split(/\s|,/); const m = /([\d+\.]+)/.exec(v);
keys.shift(); return semver.minVersion(m[0]).version;
return semver.minVersion(keys.shift()).version;
}, },
}, },
}; };