get server version

This commit is contained in:
Jan Prochazka
2021-04-25 10:25:16 +02:00
parent 08692dc63f
commit 8ff706a17f
8 changed files with 88 additions and 2 deletions

View File

@@ -80,7 +80,17 @@ const driver = {
},
async getVersion(pool) {
const { version } = (await this.query(pool, 'SELECT @@VERSION AS version')).rows[0];
return { version };
const { productVersion } = (
await this.query(pool, "SELECT SERVERPROPERTY ('productversion') as productVersion")
).rows[0];
let productVersionNumber = 0;
if (productVersion) {
const splitted = productVersion.split('.');
const number = parseInt(splitted[0]) || 0;
productVersionNumber = number;
}
return { version, productVersion, productVersionNumber };
},
async listDatabases(pool) {
const { rows } = await this.query(pool, 'SELECT name FROM sys.databases order by name');