better display of server version

This commit is contained in:
Jan Prochazka 2021-04-25 12:28:18 +02:00
parent d0cbd5d0a4
commit a8a9afc936
5 changed files with 38 additions and 13 deletions

View File

@ -65,7 +65,7 @@
<div class="item flex" title={$serverVersion.version}>
<FontIcon icon="icon version" />
<div class="version ml-1">
{$serverVersion.version}
{$serverVersion.versionText || $serverVersion.version}
</div>
</div>
{/if}

View File

@ -178,7 +178,10 @@ const driver = {
},
async getVersion(pool) {
const status = await pool.__getDatabase().admin().serverInfo();
return status;
return {
...status,
versionText: `MongoDB ${status.version}`,
};
},
async listDatabases(pool) {
const res = await pool.__getDatabase().admin().listDatabases();

View File

@ -11,6 +11,24 @@ const { tediousConnect, tediousQueryCore, tediousReadQuery, tediousStream } = re
const { nativeConnect, nativeQueryCore, nativeReadQuery, nativeStream } = nativeDriver;
let msnodesqlv8;
const versionQuery = `
SELECT
@@VERSION AS version,
SERVERPROPERTY ('productversion') as productVersion,
CASE
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '8%' THEN 'SQL Server 2000'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '9%' THEN 'SQL Server 2005'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '10.0%' THEN 'SQL Server 2008'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '10.5%' THEN 'SQL Server 2008 R2'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '11%' THEN 'SQL Server 2012'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '12%' THEN 'SQL Server 2014'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '13%' THEN 'SQL Server 2016'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '14%' THEN 'SQL Server 2017'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '15%' THEN 'SQL Server 2019'
ELSE 'Unknown'
END AS versionText
`;
const windowsAuthTypes = [
{
title: 'Windows',
@ -79,18 +97,16 @@ const driver = {
}
},
async getVersion(pool) {
const { version } = (await this.query(pool, 'SELECT @@VERSION AS version')).rows[0];
const res = (await this.query(pool, versionQuery)).rows[0];
const { productVersion } = (
await this.query(pool, "SELECT SERVERPROPERTY ('productversion') as productVersion")
).rows[0];
let productVersionNumber = 0;
if (productVersion) {
const splitted = productVersion.split('.');
if (res.productVersion) {
const splitted = res.productVersion.split('.');
const number = parseInt(splitted[0]) || 0;
productVersionNumber = number;
res.productVersionNumber = number;
} else {
res.productVersionNumber = 0;
}
return { version, productVersion, productVersionNumber };
return res;
},
async listDatabases(pool) {
const { rows } = await this.query(pool, 'SELECT name FROM sys.databases order by name');

View File

@ -171,7 +171,10 @@ const driver = {
async getVersion(connection) {
const { rows } = await this.query(connection, "show variables like 'version'");
const version = rows[0].Value;
return { version };
return {
version,
versionText: `MySQL ${version}`,
};
},
async listDatabases(connection) {
const { rows } = await this.query(connection, 'show databases');

View File

@ -141,7 +141,10 @@ const driver = {
async getVersion(client) {
const { rows } = await this.query(client, 'SELECT version()');
const { version } = rows[0];
return { version };
return {
version,
versionText: (version || '').replace(/\s*\(.*$/, ''),
};
},
// async analyseFull(pool) {
// const analyser = new PostgreAnalyser(pool, this);