mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 13:05:58 +00:00
safe mysql analyser
This commit is contained in:
@@ -229,6 +229,17 @@ export class DatabaseAnalyser {
|
|||||||
return [..._compact(res), ...this.getDeletedObjects(snapshot)];
|
return [..._compact(res), ...this.getDeletedObjects(snapshot)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async safeQuery(sql) {
|
||||||
|
try {
|
||||||
|
return await this.driver.query(this.pool, sql);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Error running analyser query', err.message);
|
||||||
|
return {
|
||||||
|
rows: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static createEmptyStructure(): DatabaseInfo {
|
static createEmptyStructure(): DatabaseInfo {
|
||||||
return {
|
return {
|
||||||
tables: [],
|
tables: [],
|
||||||
|
|||||||
@@ -65,17 +65,14 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
async _runAnalysis() {
|
async _runAnalysis() {
|
||||||
const tables = await this.driver.query(this.pool, this.createQuery('tables', ['tables']));
|
const tables = await this.driver.query(this.pool, this.createQuery('tables', ['tables']));
|
||||||
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views']));
|
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views']));
|
||||||
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables']));
|
const pkColumns = await this.safeQuery(this.createQuery('primaryKeys', ['tables']));
|
||||||
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables']));
|
const fkColumns = await this.safeQuery(this.createQuery('foreignKeys', ['tables']));
|
||||||
const views = await this.driver.query(this.pool, this.createQuery('views', ['views']));
|
const views = await this.safeQuery(this.createQuery('views', ['views']));
|
||||||
const programmables = await this.driver.query(
|
const programmables = await this.safeQuery(this.createQuery('programmables', ['procedures', 'functions']));
|
||||||
this.pool,
|
|
||||||
this.createQuery('programmables', ['procedures', 'functions'])
|
|
||||||
);
|
|
||||||
|
|
||||||
const viewTexts = await this.getViewTexts(views.rows.map(x => x.pureName));
|
const viewTexts = await this.getViewTexts(views.rows.map(x => x.pureName));
|
||||||
const indexes = await this.driver.query(this.pool, this.createQuery('indexes', ['tables']));
|
const indexes = await this.safeQuery(this.createQuery('indexes', ['tables']));
|
||||||
const uniqueNames = await this.driver.query(this.pool, this.createQuery('uniqueNames', ['tables']));
|
const uniqueNames = await this.safeQuery(this.createQuery('uniqueNames', ['tables']));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tables: tables.rows.map(table => ({
|
tables: tables.rows.map(table => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user