analyser refactor + optimalization

This commit is contained in:
Jan Prochazka
2023-01-21 10:13:08 +01:00
parent 3dfae351a6
commit f9f879272b
5 changed files with 116 additions and 127 deletions

View File

@@ -197,7 +197,7 @@ export class DatabaseAnalyser {
.filter(x => typeFields.includes(x.objectTypeField) && (x.action == 'add' || x.action == 'change')) .filter(x => typeFields.includes(x.objectTypeField) && (x.action == 'add' || x.action == 'change'))
.map(x => x.objectId); .map(x => x.objectId);
if (filterIds.length == 0) { if (filterIds.length == 0) {
return template.replace(/=OBJECT_ID_CONDITION/g, " = '0'"); return null;
} }
return template.replace(/=OBJECT_ID_CONDITION/g, ` in (${filterIds.map(x => `'${x}'`).join(',')})`); return template.replace(/=OBJECT_ID_CONDITION/g, ` in (${filterIds.map(x => `'${x}'`).join(',')})`);
} }
@@ -293,7 +293,14 @@ export class DatabaseAnalyser {
return [..._compact(res), ...this.getDeletedObjects(snapshot)]; return [..._compact(res), ...this.getDeletedObjects(snapshot)];
} }
async safeQuery(sql) { async analyserQuery(template, typeFields) {
const sql = this.createQuery(template, typeFields);
if (!sql) {
return {
rows: [],
};
}
try { try {
return await this.driver.query(this.pool, sql); return await this.driver.query(this.pool, sql);
} catch (err) { } catch (err) {

View File

@@ -82,33 +82,35 @@ class MsSqlAnalyser extends DatabaseAnalyser {
async _runAnalysis() { async _runAnalysis() {
this.feedback({ analysingMessage: 'Loading tables' }); this.feedback({ analysingMessage: 'Loading tables' });
const tablesRows = await this.driver.query(this.pool, this.createQuery('tables', ['tables'])); const tablesRows = await this.analyserQuery('tables', ['tables']);
this.feedback({ analysingMessage: 'Loading columns' }); this.feedback({ analysingMessage: 'Loading columns' });
const columnsRows = await this.driver.query(this.pool, this.createQuery('columns', ['tables'])); const columnsRows = await this.analyserQuery('columns', ['tables']);
this.feedback({ analysingMessage: 'Loading primary keys' }); this.feedback({ analysingMessage: 'Loading primary keys' });
const pkColumnsRows = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables'])); const pkColumnsRows = await this.analyserQuery('primaryKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading foreign keys' }); this.feedback({ analysingMessage: 'Loading foreign keys' });
const fkColumnsRows = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables'])); const fkColumnsRows = await this.analyserQuery('foreignKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading schemas' }); this.feedback({ analysingMessage: 'Loading schemas' });
const schemaRows = await this.driver.query(this.pool, this.createQuery('getSchemas')); const schemaRows = await this.analyserQuery('getSchemas');
this.feedback({ analysingMessage: 'Loading indexes' }); this.feedback({ analysingMessage: 'Loading indexes' });
const indexesRows = await this.driver.query(this.pool, this.createQuery('indexes', ['tables'])); const indexesRows = await this.analyserQuery('indexes', ['tables']);
this.feedback({ analysingMessage: 'Loading index columns' }); this.feedback({ analysingMessage: 'Loading index columns' });
const indexcolsRows = await this.driver.query(this.pool, this.createQuery('indexcols', ['tables'])); const indexcolsRows = await this.analyserQuery('indexcols', ['tables']);
this.feedback({ analysingMessage: 'Loading default schema' }); this.feedback({ analysingMessage: 'Loading default schema' });
const defaultSchemaRows = await this.driver.query(this.pool, 'SELECT SCHEMA_NAME() as name'); const defaultSchemaRows = await this.query(this.pool, 'SELECT SCHEMA_NAME() as name');
this.feedback({ analysingMessage: 'Loading table sizes' }); this.feedback({ analysingMessage: 'Loading table sizes' });
const tableSizes = await this.driver.query(this.pool, this.createQuery('tableSizes')); const tableSizes = await this.analyserQuery('tableSizes');
const schemas = schemaRows.rows; const schemas = schemaRows.rows;
const tableSizesDict = _.mapValues(_.keyBy(tableSizes.rows, 'objectId'), 'tableRowCount'); const tableSizesDict = _.mapValues(_.keyBy(tableSizes.rows, 'objectId'), 'tableRowCount');
this.feedback({ analysingMessage: 'Loading SQL code' }); this.feedback({ analysingMessage: 'Loading SQL code' });
const sqlCodeRows = await this.driver.query( const sqlCodeRows = await this.analyserQuery('loadSqlCode', [
this.pool, 'views',
this.createQuery('loadSqlCode', ['views', 'procedures', 'functions', 'triggers']) 'procedures',
); 'functions',
'triggers',
]);
const getCreateSql = row => const getCreateSql = row =>
sqlCodeRows.rows sqlCodeRows.rows
.filter(x => x.pureName == row.pureName && x.schemaName == row.schemaName) .filter(x => x.pureName == row.pureName && x.schemaName == row.schemaName)
@@ -116,14 +118,11 @@ class MsSqlAnalyser extends DatabaseAnalyser {
.join(''); .join('');
this.feedback({ analysingMessage: 'Loading views' }); this.feedback({ analysingMessage: 'Loading views' });
const viewsRows = await this.driver.query(this.pool, this.createQuery('views', ['views'])); const viewsRows = await this.analyserQuery('views', ['views']);
this.feedback({ analysingMessage: 'Loading procedures & functions' }); this.feedback({ analysingMessage: 'Loading procedures & functions' });
const programmableRows = await this.driver.query( const programmableRows = await this.analyserQuery('programmables', ['procedures', 'functions']);
this.pool,
this.createQuery('programmables', ['procedures', 'functions'])
);
this.feedback({ analysingMessage: 'Loading view columns' }); this.feedback({ analysingMessage: 'Loading view columns' });
const viewColumnRows = await this.driver.query(this.pool, this.createQuery('viewColumns', ['views'])); const viewColumnRows = await this.analyserQuery('viewColumns', ['views']);
this.feedback({ analysingMessage: 'Finalizing DB structure' }); this.feedback({ analysingMessage: 'Finalizing DB structure' });
const tables = tablesRows.rows.map(row => ({ const tables = tablesRows.rows.map(row => ({
@@ -190,8 +189,8 @@ class MsSqlAnalyser extends DatabaseAnalyser {
} }
async _getFastSnapshot() { async _getFastSnapshot() {
const modificationsQueryData = await this.driver.query(this.pool, this.createQuery('modifications')); const modificationsQueryData = await this.analyserQuery('modifications');
const tableSizes = await this.driver.query(this.pool, this.createQuery('tableSizes')); const tableSizes = await this.analyserQuery('tableSizes');
const res = DatabaseAnalyser.createEmptyStructure(); const res = DatabaseAnalyser.createEmptyStructure();
for (const item of modificationsQueryData.rows) { for (const item of modificationsQueryData.rows) {

View File

@@ -57,7 +57,7 @@ class Analyser extends DatabaseAnalyser {
async getViewTexts(allViewNames) { async getViewTexts(allViewNames) {
const res = {}; const res = {};
const views = await this.safeQuery(this.createQuery('viewTexts', ['views'])); const views = await this.analyserQuery('viewTexts', ['views']);
for (const view of views.rows) { for (const view of views.rows) {
res[view.pureName] = `CREATE VIEW \`${view.pureName}\` AS ${view.viewDefinition}`; res[view.pureName] = `CREATE VIEW \`${view.pureName}\` AS ${view.viewDefinition}`;
} }
@@ -76,24 +76,24 @@ class Analyser extends DatabaseAnalyser {
async _runAnalysis() { async _runAnalysis() {
this.feedback({ analysingMessage: 'Loading tables' }); this.feedback({ analysingMessage: 'Loading tables' });
const tables = await this.driver.query(this.pool, this.createQuery('tables', ['tables'])); const tables = await this.analyserQuery('tables', ['tables']);
this.feedback({ analysingMessage: 'Loading columns' }); this.feedback({ analysingMessage: 'Loading columns' });
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views'])); const columns = await this.analyserQuery('columns', ['tables', 'views']);
this.feedback({ analysingMessage: 'Loading primary keys' }); this.feedback({ analysingMessage: 'Loading primary keys' });
const pkColumns = await this.safeQuery(this.createQuery('primaryKeys', ['tables'])); const pkColumns = await this.analyserQuery('primaryKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading foreign keys' }); this.feedback({ analysingMessage: 'Loading foreign keys' });
const fkColumns = await this.safeQuery(this.createQuery('foreignKeys', ['tables'])); const fkColumns = await this.analyserQuery('foreignKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading views' }); this.feedback({ analysingMessage: 'Loading views' });
const views = await this.safeQuery(this.createQuery('views', ['views'])); const views = await this.analyserQuery('views', ['views']);
this.feedback({ analysingMessage: 'Loading programmables' }); this.feedback({ analysingMessage: 'Loading programmables' });
const programmables = await this.safeQuery(this.createQuery('programmables', ['procedures', 'functions'])); const programmables = await this.analyserQuery('programmables', ['procedures', 'functions']);
this.feedback({ analysingMessage: 'Loading view texts' }); this.feedback({ analysingMessage: 'Loading view texts' });
const viewTexts = await this.getViewTexts(views.rows.map(x => x.pureName)); const viewTexts = await this.getViewTexts(views.rows.map(x => x.pureName));
this.feedback({ analysingMessage: 'Loading indexes' }); this.feedback({ analysingMessage: 'Loading indexes' });
const indexes = await this.safeQuery(this.createQuery('indexes', ['tables'])); const indexes = await this.analyserQuery('indexes', ['tables']);
this.feedback({ analysingMessage: 'Loading uniques' }); this.feedback({ analysingMessage: 'Loading uniques' });
const uniqueNames = await this.safeQuery(this.createQuery('uniqueNames', ['tables'])); const uniqueNames = await this.analyserQuery('uniqueNames', ['tables']);
this.feedback({ analysingMessage: 'Finalizing DB structure' }); this.feedback({ analysingMessage: 'Finalizing DB structure' });
const res = { const res = {
@@ -169,15 +169,9 @@ class Analyser extends DatabaseAnalyser {
} }
async _getFastSnapshot() { async _getFastSnapshot() {
const tableModificationsQueryData = await this.driver.query(this.pool, this.createQuery('tableModifications')); const tableModificationsQueryData = await this.analyserQuery('tableModifications');
const procedureModificationsQueryData = await this.driver.query( const procedureModificationsQueryData = await this.analyserQuery('procedureModifications');
this.pool, const functionModificationsQueryData = await this.analyserQuery('functionModifications');
this.createQuery('procedureModifications')
);
const functionModificationsQueryData = await this.driver.query(
this.pool,
this.createQuery('functionModifications')
);
return { return {
tables: tableModificationsQueryData.rows tables: tableModificationsQueryData.rows

View File

@@ -68,45 +68,40 @@ class Analyser extends DatabaseAnalyser {
async _runAnalysis() { async _runAnalysis() {
this.feedback({ analysingMessage: 'Loading tables' }); this.feedback({ analysingMessage: 'Loading tables' });
const tables = await this.driver.query( const tables = await this.analyserQuery(this.driver.dialect.stringAgg ? 'tableList' : 'tableList', ['tables']);
this.pool,
this.createQuery(this.driver.dialect.stringAgg ? 'tableList' : 'tableList', ['tables'])
);
this.feedback({ analysingMessage: 'Loading columns' }); this.feedback({ analysingMessage: 'Loading columns' });
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views'])); const columns = await this.analyserQuery('columns', ['tables', 'views']);
this.feedback({ analysingMessage: 'Loading primary keys' }); this.feedback({ analysingMessage: 'Loading primary keys' });
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables'])); const pkColumns = await this.analyserQuery('primaryKeys', ['tables']);
//let fkColumns = null; //let fkColumns = null;
this.feedback({ analysingMessage: 'Loading foreign keys' }); this.feedback({ analysingMessage: 'Loading foreign keys' });
const fkColumns = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables'])); const fkColumns = await this.analyserQuery('foreignKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading views' }); this.feedback({ analysingMessage: 'Loading views' });
const views = await this.driver.query(this.pool, this.createQuery('views', ['views'])); const views = await this.analyserQuery('views', ['views']);
let geometryColumns = { rows: [] }; let geometryColumns = { rows: [] };
let geographyColumns = { rows: [] }; let geographyColumns = { rows: [] };
this.feedback({ analysingMessage: 'Loading materialized views' }); this.feedback({ analysingMessage: 'Loading materialized views' });
const matviews = this.driver.dialect.materializedViews const matviews = this.driver.dialect.materializedViews ? await this.analyserQuery('matviews', ['matviews']) : null;
? await this.driver.query(this.pool, this.createQuery('matviews', ['matviews']))
: null;
this.feedback({ analysingMessage: 'Loading materialized view columns' }); this.feedback({ analysingMessage: 'Loading materialized view columns' });
const matviewColumns = this.driver.dialect.materializedViews const matviewColumns = this.driver.dialect.materializedViews
? await this.driver.query(this.pool, this.createQuery('matviewColumns', ['matviews'])) ? await this.analyserQuery('matviewColumns', ['matviews'])
: null; : null;
this.feedback({ analysingMessage: 'Loading routines' }); this.feedback({ analysingMessage: 'Loading routines' });
const routines = await this.driver.query(this.pool, this.createQuery('routines', ['procedures', 'functions'])); const routines = await this.analyserQuery('routines', ['procedures', 'functions']);
this.feedback({ analysingMessage: 'Loading indexes' }); this.feedback({ analysingMessage: 'Loading indexes' });
const indexes = this.driver.__analyserInternals.skipIndexes const indexes = this.driver.__analyserInternals.skipIndexes
? { rows: [] } ? { rows: [] }
: await this.driver.query(this.pool, this.createQuery('indexes', ['tables'])); : await this.analyserQuery('indexes', ['tables']);
this.feedback({ analysingMessage: 'Loading index columns' }); this.feedback({ analysingMessage: 'Loading index columns' });
// const indexcols = this.driver.__analyserInternals.skipIndexes // const indexcols = this.driver.__analyserInternals.skipIndexes
// ? { rows: [] } // ? { rows: [] }
// : await this.driver.query(this.pool, this.createQuery('indexcols', ['tables'])); // : await this.driver.query(this.pool, this.createQuery('indexcols', ['tables']));
this.feedback({ analysingMessage: 'Loading unique names' }); this.feedback({ analysingMessage: 'Loading unique names' });
const uniqueNames = await this.driver.query(this.pool, this.createQuery('uniqueNames', ['tables'])); const uniqueNames = await this.analyserQuery('uniqueNames', ['tables']);
this.feedback({ analysingMessage: 'Finalizing DB structure' }); this.feedback({ analysingMessage: 'Finalizing DB structure' });
const columnColumnsMapped = fkColumns.rows.map(x => ({ const columnColumnsMapped = fkColumns.rows.map(x => ({
@@ -144,34 +139,35 @@ class Analyser extends DatabaseAnalyser {
.map(col => getColumnInfo(col, newTable, geometryColumns, geographyColumns)), .map(col => getColumnInfo(col, newTable, geometryColumns, geographyColumns)),
primaryKey: DatabaseAnalyser.extractPrimaryKeys(newTable, pkColumnsMapped), primaryKey: DatabaseAnalyser.extractPrimaryKeys(newTable, pkColumnsMapped),
foreignKeys: DatabaseAnalyser.extractForeignKeys(newTable, columnColumnsMapped), foreignKeys: DatabaseAnalyser.extractForeignKeys(newTable, columnColumnsMapped),
indexes: _.uniqBy( indexes: _.uniqBy(
indexes.rows.filter( indexes.rows.filter(
idx => idx =>
idx.tableName == table.pureName && !uniqueNames.rows.find(x => x.constraintName == idx.constraintName) idx.tableName == table.pureName && !uniqueNames.rows.find(x => x.constraintName == idx.constraintName)
), ),
'constraintName' 'constraintName'
).map(idx => ({ ).map(idx => ({
..._.pick(idx, ['constraintName', 'indexType']), ..._.pick(idx, ['constraintName', 'indexType']),
isUnique: idx.Unique === 'UNIQUE', isUnique: idx.Unique === 'UNIQUE',
columns: indexes.rows columns: indexes.rows
.filter(col => col.tableName == idx.tableName && col.constraintName == idx.constraintName) .filter(col => col.tableName == idx.tableName && col.constraintName == idx.constraintName)
.map(col => ({ .map(col => ({
..._.pick(col, ['columnName']), ..._.pick(col, ['columnName']),
})), })),
})), })),
uniques: _.uniqBy( uniques: _.uniqBy(
indexes.rows.filter( indexes.rows.filter(
idx => idx.tableName == table.pureName && uniqueNames.rows.find(x => x.constraintName == idx.constraintName) idx =>
), idx.tableName == table.pureName && uniqueNames.rows.find(x => x.constraintName == idx.constraintName)
'constraintName' ),
).map(idx => ({ 'constraintName'
..._.pick(idx, ['constraintName']), ).map(idx => ({
columns: indexes.rows ..._.pick(idx, ['constraintName']),
.filter(col => col.tableName == idx.tableName && col.constraintName == idx.constraintName) columns: indexes.rows
.map(col => ({ .filter(col => col.tableName == idx.tableName && col.constraintName == idx.constraintName)
..._.pick(col, ['columnName']), .map(col => ({
})), ..._.pick(col, ['columnName']),
})), })),
})),
}; };
}), }),
views: views.rows.map(view => ({ views: views.rows.map(view => ({
@@ -225,13 +221,13 @@ class Analyser extends DatabaseAnalyser {
return null; return null;
const tableModificationsQueryData = this.driver.dialect.stringAgg const tableModificationsQueryData = this.driver.dialect.stringAgg
? await this.driver.query(this.pool, this.createQuery('tableModifications')) ? await this.analyserQuery('tableModifications')
: null; : null;
const viewModificationsQueryData = await this.driver.query(this.pool, this.createQuery('viewModifications')); const viewModificationsQueryData = await this.analyserQuery('viewModifications');
const matviewModificationsQueryData = this.driver.dialect.materializedViews const matviewModificationsQueryData = this.driver.dialect.materializedViews
? await this.driver.query(this.pool, this.createQuery('matviewModifications')) ? await this.analyserQuery('matviewModifications')
: null; : null;
const routineModificationsQueryData = await this.driver.query(this.pool, this.createQuery('routineModifications')); const routineModificationsQueryData = await this.analyserQuery('routineModifications');
return { return {
tables: tableModificationsQueryData tables: tableModificationsQueryData
@@ -243,13 +239,13 @@ class Analyser extends DatabaseAnalyser {
})) }))
: null, : null,
views: viewModificationsQueryData views: viewModificationsQueryData
? viewModificationsQueryData.rows.map(x => ({ ? viewModificationsQueryData.rows.map(x => ({
objectId: `views:${x.schema_name}.${x.pure_name}`, objectId: `views:${x.schema_name}.${x.pure_name}`,
pureName: x.pure_name, pureName: x.pure_name,
schemaName: x.schema_name, schemaName: x.schema_name,
contentHash: x.hash_code, contentHash: x.hash_code,
})) }))
: undefined, : undefined,
matviews: matviewModificationsQueryData matviews: matviewModificationsQueryData
? matviewModificationsQueryData.rows.map(x => ({ ? matviewModificationsQueryData.rows.map(x => ({
objectId: `matviews:${x.schema_name}.${x.pure_name}`, objectId: `matviews:${x.schema_name}.${x.pure_name}`,

View File

@@ -67,28 +67,23 @@ class Analyser extends DatabaseAnalyser {
async _runAnalysis() { async _runAnalysis() {
this.feedback({ analysingMessage: 'Loading tables' }); this.feedback({ analysingMessage: 'Loading tables' });
const tables = await this.driver.query( const tables = await this.analyserQuery(this.driver.dialect.stringAgg ? 'tableModifications' : 'tableList', [
this.pool, 'tables',
this.createQuery(this.driver.dialect.stringAgg ? 'tableModifications' : 'tableList', ['tables']) ]);
);
this.feedback({ analysingMessage: 'Loading columns' }); this.feedback({ analysingMessage: 'Loading columns' });
const columns = await this.driver.query(this.pool, this.createQuery('columns', ['tables', 'views'])); const columns = await this.analyserQuery('columns', ['tables', 'views']);
this.feedback({ analysingMessage: 'Loading primary keys' }); this.feedback({ analysingMessage: 'Loading primary keys' });
const pkColumns = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables'])); const pkColumns = await this.analyserQuery('primaryKeys', ['tables']);
let fkColumns = null; let fkColumns = null;
this.feedback({ analysingMessage: 'Loading foreign key constraints' }); this.feedback({ analysingMessage: 'Loading foreign key constraints' });
const fk_tableConstraints = await this.driver.query(this.pool, this.createQuery('fk_tableConstraints', ['tables'])); const fk_tableConstraints = await this.analyserQuery('fk_tableConstraints', ['tables']);
this.feedback({ analysingMessage: 'Loading foreign key refs' }); this.feedback({ analysingMessage: 'Loading foreign key refs' });
const fk_referentialConstraints = await this.driver.query( const fk_referentialConstraints = await this.analyserQuery('fk_referentialConstraints', ['tables']);
this.pool,
this.createQuery('fk_referentialConstraints', ['tables'])
);
this.feedback({ analysingMessage: 'Loading foreign key columns' }); this.feedback({ analysingMessage: 'Loading foreign key columns' });
const fk_keyColumnUsage = await this.driver.query(this.pool, this.createQuery('fk_keyColumnUsage', ['tables'])); const fk_keyColumnUsage = await this.analyserQuery('fk_keyColumnUsage', ['tables']);
const cntKey = x => `${x.constraint_name}|${x.constraint_schema}`; const cntKey = x => `${x.constraint_name}|${x.constraint_schema}`;
const fkRows = []; const fkRows = [];
@@ -129,37 +124,35 @@ class Analyser extends DatabaseAnalyser {
fkColumns = { rows: fkRows }; fkColumns = { rows: fkRows };
this.feedback({ analysingMessage: 'Loading views' }); this.feedback({ analysingMessage: 'Loading views' });
const views = await this.driver.query(this.pool, this.createQuery('views', ['views'])); const views = await this.analyserQuery('views', ['views']);
this.feedback({ analysingMessage: 'Loading materialized views' }); this.feedback({ analysingMessage: 'Loading materialized views' });
const matviews = this.driver.dialect.materializedViews const matviews = this.driver.dialect.materializedViews ? await this.analyserQuery('matviews', ['matviews']) : null;
? await this.driver.query(this.pool, this.createQuery('matviews', ['matviews']))
: null;
this.feedback({ analysingMessage: 'Loading materialized view columns' }); this.feedback({ analysingMessage: 'Loading materialized view columns' });
const matviewColumns = this.driver.dialect.materializedViews const matviewColumns = this.driver.dialect.materializedViews
? await this.driver.query(this.pool, this.createQuery('matviewColumns', ['matviews'])) ? await this.analyserQuery('matviewColumns', ['matviews'])
: null; : null;
this.feedback({ analysingMessage: 'Loading routines' }); this.feedback({ analysingMessage: 'Loading routines' });
const routines = await this.driver.query(this.pool, this.createQuery('routines', ['procedures', 'functions'])); const routines = await this.analyserQuery('routines', ['procedures', 'functions']);
this.feedback({ analysingMessage: 'Loading indexes' }); this.feedback({ analysingMessage: 'Loading indexes' });
const indexes = this.driver.__analyserInternals.skipIndexes const indexes = this.driver.__analyserInternals.skipIndexes
? { rows: [] } ? { rows: [] }
: await this.driver.query(this.pool, this.createQuery('indexes', ['tables'])); : await this.analyserQuery('indexes', ['tables']);
this.feedback({ analysingMessage: 'Loading index columns' }); this.feedback({ analysingMessage: 'Loading index columns' });
const indexcols = this.driver.__analyserInternals.skipIndexes const indexcols = this.driver.__analyserInternals.skipIndexes
? { rows: [] } ? { rows: [] }
: await this.driver.query(this.pool, this.createQuery('indexcols', ['tables'])); : await this.analyserQuery('indexcols', ['tables']);
this.feedback({ analysingMessage: 'Loading unique names' }); this.feedback({ analysingMessage: 'Loading unique names' });
const uniqueNames = await this.driver.query(this.pool, this.createQuery('uniqueNames', ['tables'])); const uniqueNames = await this.analyserQuery('uniqueNames', ['tables']);
let geometryColumns = { rows: [] }; let geometryColumns = { rows: [] };
if (views.rows.find(x => x.pure_name == 'geometry_columns' && x.schema_name == 'public')) { if (views.rows.find(x => x.pure_name == 'geometry_columns' && x.schema_name == 'public')) {
this.feedback({ analysingMessage: 'Loading geometry columns' }); this.feedback({ analysingMessage: 'Loading geometry columns' });
geometryColumns = await this.safeQuery(this.createQuery('geometryColumns', ['tables'])); geometryColumns = await this.analyserQuery('geometryColumns', ['tables']);
} }
let geographyColumns = { rows: [] }; let geographyColumns = { rows: [] };
if (views.rows.find(x => x.pure_name == 'geography_columns' && x.schema_name == 'public')) { if (views.rows.find(x => x.pure_name == 'geography_columns' && x.schema_name == 'public')) {
this.feedback({ analysingMessage: 'Loading geography columns' }); this.feedback({ analysingMessage: 'Loading geography columns' });
geographyColumns = await this.safeQuery(this.createQuery('geographyColumns', ['tables'])); geographyColumns = await this.analyserQuery('geographyColumns', ['tables']);
} }
this.feedback({ analysingMessage: 'Finalizing DB structure' }); this.feedback({ analysingMessage: 'Finalizing DB structure' });
@@ -289,13 +282,13 @@ class Analyser extends DatabaseAnalyser {
async _getFastSnapshot() { async _getFastSnapshot() {
const tableModificationsQueryData = this.driver.dialect.stringAgg const tableModificationsQueryData = this.driver.dialect.stringAgg
? await this.driver.query(this.pool, this.createQuery('tableModifications')) ? await this.analyserQuery('tableModifications')
: null; : null;
const viewModificationsQueryData = await this.driver.query(this.pool, this.createQuery('viewModifications')); const viewModificationsQueryData = await this.analyserQuery('viewModifications');
const matviewModificationsQueryData = this.driver.dialect.materializedViews const matviewModificationsQueryData = this.driver.dialect.materializedViews
? await this.driver.query(this.pool, this.createQuery('matviewModifications')) ? await this.analyserQuery('matviewModifications')
: null; : null;
const routineModificationsQueryData = await this.driver.query(this.pool, this.createQuery('routineModifications')); const routineModificationsQueryData = await this.analyserQuery('routineModifications');
return { return {
tables: tableModificationsQueryData tables: tableModificationsQueryData