mssql - incremental analysis

This commit is contained in:
Jan Prochazka
2020-04-11 20:24:30 +02:00
parent eb0c2f04bd
commit fae97a8b4a
12 changed files with 288 additions and 87 deletions

View File

@@ -9,29 +9,22 @@ class MySqlAnalyser extends DatabaseAnalayser {
super(pool, driver);
}
async createQuery(
resFileName,
tables = false,
views = false,
procedures = false,
functions = false,
triggers = false
) {
createQuery(resFileName, tables = false, views = false, procedures = false, functions = false, triggers = false) {
let res = sql[resFileName];
res = res.replace('=[OBJECT_NAME_CONDITION]', ' is not null');
res = res.replace('#DATABASE#', this.pool._database_name);
return res;
}
async runAnalysis() {
const tables = await this.driver.query(this.pool, await this.createQuery('tables'));
const columns = await this.driver.query(this.pool, await this.createQuery('columns'));
// const pkColumns = await this.driver.query(this.pool, await this.createQuery('primary_keys.sql'));
// const fkColumns = await this.driver.query(this.pool, await this.createQuery('foreign_keys.sql'));
const tables = await this.driver.query(this.pool, this.createQuery('tables'));
const columns = await this.driver.query(this.pool, this.createQuery('columns'));
// const pkColumns = await this.driver.query(this.pool, this.createQuery('primary_keys.sql'));
// const fkColumns = await this.driver.query(this.pool, this.createQuery('foreign_keys.sql'));
this.result.tables = tables.rows.map(table => ({
this.result.tables = tables.rows.map((table) => ({
...table,
columns: columns.rows
.filter(col => col.pureName == table.pureName)
.filter((col) => col.pureName == table.pureName)
.map(({ isNullable, extra, ...col }) => ({
...col,
notNull: !isNullable,