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) {