backend bundle refactor

This commit is contained in:
Jan Prochazka
2020-03-14 10:38:10 +01:00
parent cd58555409
commit 1d63908328
15 changed files with 66 additions and 53 deletions

View File

@@ -1,13 +1,9 @@
const fp = require('lodash/fp');
const _ = require('lodash');
const sql = require('./sql')
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
/** @returns {Promise<string>} */
async function loadQuery(pool, name) {
return await pool._nativeModules.fs.readFile(pool._nativeModules.path.join(__dirname, name), 'utf-8');
}
const byTableFilter = table => x => x.pureName == table.pureName && x.schemaName == x.schemaName;
function extractPrimaryKeys(table, pkColumns) {
@@ -184,15 +180,15 @@ class MsSqlAnalyser extends DatabaseAnalayser {
functions = false,
triggers = false
) {
let res = await loadQuery(this.pool, resFileName);
let res = sql[resFileName];
res = res.replace('=[OBJECT_ID_CONDITION]', ' is not null');
return res;
}
async runAnalysis() {
const tables = await this.driver.query(this.pool, await this.createQuery('tables.sql'));
const columns = await this.driver.query(this.pool, await this.createQuery('columns.sql'));
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, 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('primaryKeys'));
const fkColumns = await this.driver.query(this.pool, await this.createQuery('foreignKeys'));
this.result.tables = tables.rows.map(table => ({
...table,