Skip to content

Commit

Permalink
fix: missing header for some query results
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Oct 9, 2020
1 parent 9ecd888 commit d560c38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/WorkspaceQueryTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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 });
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/WorkspaceQueryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
:class="{'active': resultsetIndex === index}"
@click="selectResultset(index)"
>
<a>{{ result.fields ? result.fields[0].orgTable : '' }} ({{ result.rows.length }})</a>
<a>{{ result.fields ? result.fields[0].table : '' }} ({{ result.rows.length }})</a>
</li>
</ul>
<div ref="table" class="table table-hover">
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d560c38

Please sign in to comment.