feat: basic firebird analyser

This commit is contained in:
Nybkox
2025-05-06 15:52:15 +02:00
parent bac8bd0006
commit 839ec9a456
17 changed files with 610 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
const _ = require('lodash');
const sql = require('./sql');
const { getDataTypeString } = require('./helpers');
const { DatabaseAnalyser } = require('dbgate-tools');
class Analyser extends DatabaseAnalyser {
constructor(dbhan, driver, version) {
super(dbhan, driver, version);
}
async _runAnalysis() {
const tablesResult = await this.driver.query(this.dbhan, sql.tables);
const columnsResult = await this.driver.query(this.dbhan, sql.columns);
const columns = columnsResult.rows.map(i => ({
tableName: i.TABLENAME,
columnName: i.COLUMNNAME,
notNull: i.NOTNULL,
isPrimaryKey: i.ISPRIMARYKEY,
dataType: getDataTypeString(i),
precision: i.NUMBERPRECISION,
scale: i.SCALE,
length: i.LENGTH,
defaultValue: i.DEFAULTVALUE,
columnComment: i.COLUMNCOMMENT,
isUnsigned: i.ISUNSIGNED,
pureName: i.PURENAME,
schemaName: i.SCHEMANAME,
}));
const tables = tablesResult.rows.map(i => ({
pureName: i.PURENAME,
objectId: i.OBJECTID,
schemaName: i.SCHEMANAME,
objectComment: i.OBJECTCOMMENT,
}));
return {
tables: tables.map(table => ({
...table,
columns: columns.filter(column => column.tableName === table.pureName),
})),
};
}
async _getFastSnapshot() {
return this._runAnalysis();
}
}
module.exports = Analyser;