diff --git a/src/main/ipc-handlers/database.js b/src/main/ipc-handlers/database.js index 122e4a72..dd42183c 100644 --- a/src/main/ipc-handlers/database.js +++ b/src/main/ipc-handlers/database.js @@ -94,6 +94,17 @@ export default connections => { } }); + ipcMain.handle('get-version', async (event, uid) => { + try { + const result = await connections[uid].getVersion(); + + return { status: 'success', response: result }; + } + catch (err) { + return { status: 'error', response: err.toString() }; + } + }); + ipcMain.handle('use-schema', async (event, { uid, schema }) => { if (!schema) return; diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index 8a52ede1..138a925a 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -920,6 +920,35 @@ export class MySQLClient extends AntaresCore { }); } + /** + * SHOW VARIABLES LIKE '%vers%' + * + * @returns {Array.} version parameters + * @memberof MySQLClient + */ + async getVersion () { + const sql = 'SHOW VARIABLES LIKE "%vers%"'; + const { rows } = await this.raw(sql); + + return rows.reduce((acc, curr) => { + switch (curr.Variable_name) { + case 'version': + acc.number = curr.Value.split('-')[0]; + break; + case 'version_comment': + acc.name = curr.Value.replace('(GPL)', ''); + break; + case 'version_compile_machine': + acc.arch = curr.Value; + break; + case 'version_compile_os': + acc.os = curr.Value; + break; + } + return acc; + }, {}); + } + /** * CREATE TABLE * @@ -1231,7 +1260,7 @@ export class MySQLClient extends AntaresCore { const response = await this.getTableColumns(paramObj); remappedFields = remappedFields.map(field => { const detailedField = response.find(f => f.name === field.name); - if (field.orgTable === paramObj.table && field.schema === paramObj.schema && detailedField.name === field.orgName) + if (detailedField && field.orgTable === paramObj.table && field.schema === paramObj.schema && detailedField.name === field.orgName) field = { ...detailedField, ...field }; return field; }); diff --git a/src/renderer/components/TheFooter.vue b/src/renderer/components/TheFooter.vue index 79243bbe..c47ded35 100644 --- a/src/renderer/components/TheFooter.vue +++ b/src/renderer/components/TheFooter.vue @@ -2,9 +2,9 @@