mirror of
https://github.com/Fabio286/antares.git
synced 2025-04-14 10:12:04 +02:00
fix: error when launching queries without a result from query tabs
This commit is contained in:
parent
801a0de186
commit
a1a6f51f2f
@ -285,15 +285,20 @@ export class AntaresConnector {
|
|||||||
switch (this._client) { // TODO: uniform fields with every client type, needed table name and fields array
|
switch (this._client) { // TODO: uniform fields with every client type, needed table name and fields array
|
||||||
case 'maria':
|
case 'maria':
|
||||||
case 'mysql': {
|
case 'mysql': {
|
||||||
const { rows, fields } = await new Promise((resolve, reject) => {
|
const { rows, report, fields } = await new Promise((resolve, reject) => {
|
||||||
this._connection.query(sql, (err, rows, fields) => {
|
this._connection.query(sql, (err, response, fields) => {
|
||||||
if (err)
|
if (err)
|
||||||
reject(err);
|
reject(err);
|
||||||
else
|
else {
|
||||||
resolve({ rows, fields });
|
resolve({
|
||||||
|
rows: Array.isArray(response) ? response : false,
|
||||||
|
report: !Array.isArray(response) ? response : false,
|
||||||
|
fields
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return { rows, fields };
|
return { rows, report, fields };
|
||||||
}
|
}
|
||||||
case 'mssql': {
|
case 'mssql': {
|
||||||
const results = await this._connection.request().query(sql);
|
const results = await this._connection.request().query(sql);
|
||||||
|
@ -201,6 +201,7 @@ export default {
|
|||||||
max-width: 320px;
|
max-width: 320px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
<div v-if="results.rows">
|
<div v-if="results.rows">
|
||||||
{{ $t('word.results') }}: <b>{{ results.rows.length }}</b>
|
{{ $t('word.results') }}: <b>{{ results.rows.length }}</b>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="results.report">
|
||||||
|
{{ $t('message.affectedRows') }}: <b>{{ results.report.affectedRows }}</b>
|
||||||
|
</div>
|
||||||
<div v-if="workspace.breadcrumbs.schema">
|
<div v-if="workspace.breadcrumbs.schema">
|
||||||
{{ $t('word.schema') }}: <b>{{ workspace.breadcrumbs.schema }}</b>
|
{{ $t('word.schema') }}: <b>{{ workspace.breadcrumbs.schema }}</b>
|
||||||
</div>
|
</div>
|
||||||
@ -94,8 +97,7 @@ export default {
|
|||||||
async runQuery (query) {
|
async runQuery (query) {
|
||||||
if (!query) return;
|
if (!query) return;
|
||||||
this.isQuering = true;
|
this.isQuering = true;
|
||||||
this.results = {};
|
this.clearTabData();
|
||||||
this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields: [] });
|
|
||||||
|
|
||||||
try { // Query Data
|
try { // Query Data
|
||||||
const params = {
|
const params = {
|
||||||
@ -107,33 +109,54 @@ export default {
|
|||||||
const { status, response } = await Connection.rawQuery(params);
|
const { status, response } = await Connection.rawQuery(params);
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
this.results = response;
|
this.results = response;
|
||||||
this.selectedFields = response.fields.map(field => field.orgName);
|
if (response.rows) { // if is a select
|
||||||
}
|
this.selectedFields = response.fields.map(field => field.orgName);
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
this.addNotification({ status: 'error', message: err.stack });
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Table data
|
try { // Table data
|
||||||
const params = {
|
const params = {
|
||||||
uid: this.connection.uid,
|
uid: this.connection.uid,
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
table: this.table
|
table: this.table
|
||||||
};
|
};
|
||||||
|
|
||||||
const { status, response } = await Tables.getTableColumns(params);
|
const { status, response } = await Tables.getTableColumns(params);
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
let fields = response.filter(field => this.selectedFields.includes(field.name));
|
let fields = response.filter(field => this.selectedFields.includes(field.name));
|
||||||
if (this.selectedFields.length) {
|
if (this.selectedFields.length) {
|
||||||
fields = fields.map((field, index) => {
|
fields = fields.map((field, index) => {
|
||||||
return { ...field, alias: this.results.fields[index].name };
|
return { ...field, alias: this.results.fields[index].name };
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
|
||||||
|
try { // Key usage (foreign keys)
|
||||||
|
const params = {
|
||||||
|
uid: this.connection.uid,
|
||||||
|
schema: this.schema,
|
||||||
|
table: this.table
|
||||||
|
};
|
||||||
|
|
||||||
|
const { status, response } = await Tables.getKeyUsage(params);
|
||||||
|
if (status === 'success')
|
||||||
|
this.setTabKeyUsage({ cUid: this.connection.uid, tUid: this.tabUid, keyUsage: response });
|
||||||
|
else
|
||||||
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { // if is a query without results
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields });
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'error', message: response });
|
this.addNotification({ status: 'error', message: response });
|
||||||
@ -142,28 +165,15 @@ export default {
|
|||||||
this.addNotification({ status: 'error', message: err.stack });
|
this.addNotification({ status: 'error', message: err.stack });
|
||||||
}
|
}
|
||||||
|
|
||||||
try { // Key usage (foreign keys)
|
|
||||||
const params = {
|
|
||||||
uid: this.connection.uid,
|
|
||||||
schema: this.schema,
|
|
||||||
table: this.table
|
|
||||||
};
|
|
||||||
|
|
||||||
const { status, response } = await Tables.getKeyUsage(params);
|
|
||||||
if (status === 'success')
|
|
||||||
this.setTabKeyUsage({ cUid: this.connection.uid, tUid: this.tabUid, keyUsage: response });
|
|
||||||
else
|
|
||||||
this.addNotification({ status: 'error', message: response });
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
this.addNotification({ status: 'error', message: err.stack });
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isQuering = false;
|
this.isQuering = false;
|
||||||
this.lastQuery = query;
|
this.lastQuery = query;
|
||||||
},
|
},
|
||||||
reloadTable () {
|
reloadTable () {
|
||||||
this.runQuery(this.lastQuery);
|
this.runQuery(this.lastQuery);
|
||||||
|
},
|
||||||
|
clearTabData () {
|
||||||
|
this.results = {};
|
||||||
|
this.setTabFields({ cUid: this.connection.uid, tUid: this.tabUid, fields: [] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -69,7 +69,8 @@ module.exports = {
|
|||||||
uploadFile: 'Upload file',
|
uploadFile: 'Upload file',
|
||||||
addNewRow: 'Add new row',
|
addNewRow: 'Add new row',
|
||||||
numberOfInserts: 'Number of inserts',
|
numberOfInserts: 'Number of inserts',
|
||||||
openNewTab: 'Open a new tab'
|
openNewTab: 'Open a new tab',
|
||||||
|
affectedRows: 'Affected rows'
|
||||||
},
|
},
|
||||||
// Date and Time
|
// Date and Time
|
||||||
short: {
|
short: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user