mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 05:36:00 +00:00
feat: basic firebird analyser
This commit is contained in:
51
plugins/dbgate-plugin-firebird/src/backend/Analyser.js
Normal file
51
plugins/dbgate-plugin-firebird/src/backend/Analyser.js
Normal 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;
|
||||
Reference in New Issue
Block a user