fix: unable to obtain fields informations for some queries

This commit is contained in:
Fabio 2020-09-20 16:03:03 +02:00
parent 530d1bd43f
commit 43c7072c1c
4 changed files with 15 additions and 5 deletions

View File

@ -89,11 +89,13 @@ export default {
}),
getResultParams (index) {
const resultsWithRows = this.results.filter(result => result.rows);
let cachedTable;
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
return {
table: field.orgTable,
table: field.orgTable || cachedTable,
schema: field.db || 'INFORMATION_SCHEMA'
};
}).filter((val, i, arr) => arr.findIndex(el => el.schema === val.schema && el.table === val.table) === i);
@ -147,6 +149,11 @@ export default {
return { ...field, alias: result.fields[fI++].name };
});
}
if (!fields.length) {
fields = response.map(field => {
return { ...field, alias: result.fields[fI++].name };
});
}
fieldsArr[qI] = fieldsArr[qI] ? [...fieldsArr[qI], ...fields] : fields;
}

View File

@ -141,11 +141,14 @@ export default {
resultsWithRows () {
return this.results.filter(result => result.rows);
},
tabProperties () {
return this.getWorkspaceTab(this.tabUid);
},
fields () {
return this.getWorkspaceTab(this.tabUid) && this.getWorkspaceTab(this.tabUid).fields[this.resultsetIndex] ? this.getWorkspaceTab(this.tabUid).fields[this.resultsetIndex] : [];
return this.tabProperties && this.tabProperties.fields[this.resultsetIndex] ? this.tabProperties.fields[this.resultsetIndex] : [];
},
keyUsage () {
return this.getWorkspaceTab(this.tabUid) && this.getWorkspaceTab(this.tabUid).keyUsage[this.resultsetIndex] ? this.getWorkspaceTab(this.tabUid).keyUsage[this.resultsetIndex] : [];
return this.tabProperties && this.tabProperties.keyUsage[this.resultsetIndex] ? this.tabProperties.keyUsage[this.resultsetIndex] : [];
}
},
watch: {

View File

@ -3,7 +3,7 @@ export default {
namespaced: true,
strict: true,
state: {
app_name: 'Antares - Database Client',
app_name: 'Antares - SQL Client',
app_version: process.env.PACKAGE_VERSION || 0,
is_loading: false,
is_new_modal: false,

View File

@ -7,7 +7,7 @@ export default {
state: {
locale: 'en-US',
explorebar_size: null,
notifications_timeout: 10
notifications_timeout: 5
},
getters: {
getLocale: state => state.locale,