From d560c384f5aed58ea975935975843c3b9061dd85 Mon Sep 17 00:00:00 2001 From: Fabio Date: Fri, 9 Oct 2020 22:44:05 +0200 Subject: [PATCH] fix: missing header for some query results --- src/main/libs/clients/MySQLClient.js | 10 +++++++++- src/renderer/components/WorkspaceQueryTab.vue | 8 ++++---- src/renderer/components/WorkspaceQueryTable.vue | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.js b/src/main/libs/clients/MySQLClient.js index 1bee3e22..f2e0286f 100644 --- a/src/main/libs/clients/MySQLClient.js +++ b/src/main/libs/clients/MySQLClient.js @@ -194,10 +194,18 @@ export class MySQLClient extends AntaresCore { if (err) reject(err); else { + const remappedFields = fields ? fields.map(field => { + return { + name: field.name, + db: field.db, + table: field.orgTable + }; + }) : []; + resolve({ rows: Array.isArray(response) ? response : false, report: !Array.isArray(response) ? response : false, - fields + fields: remappedFields }); } }); diff --git a/src/renderer/components/WorkspaceQueryTab.vue b/src/renderer/components/WorkspaceQueryTab.vue index 051a3fe9..7243da86 100644 --- a/src/renderer/components/WorkspaceQueryTab.vue +++ b/src/renderer/components/WorkspaceQueryTab.vue @@ -100,9 +100,9 @@ export default { if (resultsWithRows[index] && resultsWithRows[index].fields && resultsWithRows[index].fields.length) { return resultsWithRows[index].fields.map(field => { - if (field.orgTable) cachedTable = field.orgTable;// Needed for some queries on information_schema + if (field.table) cachedTable = field.table;// Needed for some queries on information_schema return { - table: field.orgTable || cachedTable, + table: field.table || cachedTable, schema: field.db || 'INFORMATION_SCHEMA' }; }).filter((val, i, arr) => arr.findIndex(el => el.schema === val.schema && el.table === val.table) === i); @@ -137,7 +137,7 @@ export default { if (result.rows) { // if is a select const paramsArr = this.getResultParams(qI); - selectedFields = result.fields.map(field => field.orgName); + selectedFields = result.fields.map(field => field.name); this.resultsCount += result.rows.length; for (const paramObj of paramsArr) { @@ -162,7 +162,7 @@ export default { }); } - fieldsArr[qI] = fieldsArr[qI] ? [...fieldsArr[qI], ...fields] : fields; + fieldsArr[qI] = fieldsArr[qI] ? [...fieldsArr[qI], ...fields] : fields.length ? fields : result.fields; } else this.addNotification({ status: 'error', message: response }); diff --git a/src/renderer/components/WorkspaceQueryTable.vue b/src/renderer/components/WorkspaceQueryTable.vue index fc873d10..4651e709 100644 --- a/src/renderer/components/WorkspaceQueryTable.vue +++ b/src/renderer/components/WorkspaceQueryTable.vue @@ -19,7 +19,7 @@ :class="{'active': resultsetIndex === index}" @click="selectResultset(index)" > - {{ result.fields ? result.fields[0].orgTable : '' }} ({{ result.rows.length }}) + {{ result.fields ? result.fields[0].table : '' }} ({{ result.rows.length }})
@@ -207,7 +207,7 @@ export default { }, getTable (index) { if (this.resultsWithRows[index] && this.resultsWithRows[index].fields && this.resultsWithRows[index].fields.length) - return this.resultsWithRows[index].fields[0].orgTable; + return this.resultsWithRows[index].fields[0].table; return ''; }, getSchema (index) {