fix: catch getViewTexts errors otherwise no structure can be seen

if somehow SHOW CREATE VIEW fails (invalid refs, permissions) it throw an
error and no structure is shown at all.
This commit is contained in:
Guillermo Bonvehí
2021-04-23 11:59:13 -03:00
parent 64af838f40
commit 137bb7b002

View File

@@ -79,8 +79,13 @@ class Analyser extends DatabaseAnalyser {
async getViewTexts(allViewNames) {
const res = {};
for (const viewName of this.getRequestedViewNames(allViewNames)) {
const resp = await this.driver.query(this.pool, `SHOW CREATE VIEW \`${viewName}\``);
res[viewName] = resp.rows[0]['Create View'];
try {
const resp = await this.driver.query(this.pool, `SHOW CREATE VIEW \`${viewName}\``);
res[viewName] = resp.rows[0]['Create View'];
} catch(err) {
console.log('ERROR', err);
res[viewName] = `${err}`;
}
}
return res;
}