feat: add object ids to firebird queries

This commit is contained in:
Pavel
2025-05-27 18:49:27 +02:00
parent c20cac621a
commit 1568dfc183
8 changed files with 48 additions and 19 deletions

View File

@@ -16,35 +16,46 @@ class Analyser extends DatabaseAnalyser {
}
async _runAnalysis() {
const tablesResult = await this.driver.query(this.dbhan, sql.tables);
const columnsResult = await this.driver.query(this.dbhan, sql.columns);
const triggersResult = await this.driver.query(this.dbhan, sql.triggers);
const primaryKeysResult = await this.driver.query(this.dbhan, sql.primaryKeys);
const foreignKeysResult = await this.driver.query(this.dbhan, sql.foreignKeys);
const functionsResults = await this.driver.query(this.dbhan, sql.functions);
const functionParametersResults = await this.driver.query(this.dbhan, sql.functionParameters);
const proceduresResults = await this.driver.query(this.dbhan, sql.procedures);
const procedureParametersResults = await this.driver.query(this.dbhan, sql.procedureParameters);
const tablesResult = await this.analyserQuery(sql.tables, ['tables']);
const columnsResult = await this.analyserQuery(sql.columns, ['tables', 'views']);
const triggersResult = await this.analyserQuery(sql.triggers, ['triggers']);
const primaryKeysResult = await this.analyserQuery(sql.primaryKeys, ['primaryKeys']);
const foreignKeysResult = await this.analyserQuery(sql.foreignKeys, ['foreignKeys']);
const functionsResults = await this.analyserQuery(sql.functions, ['functions']);
const functionParametersResults = await this.analyserQuery(sql.functionParameters, ['functions']);
const proceduresResults = await this.analyserQuery(sql.procedures, ['procedures']);
const procedureParametersResults = await this.analyserQuery(sql.procedureParameters, ['procedures']);
const columns = columnsResult.rows?.map(column => ({
...column,
objectId: `tables:${column.columnName}`,
dataType: getDataTypeString(column),
defaultValue: getFormattedDefaultValue(column.defaultValue),
}));
const triggers = triggersResult.rows?.map(i => ({
...i,
objectId: `triggers:${i.pureName}`,
eventType: getTriggerEventType(i.TRIGGERTYPE),
triggerTiming: getTriggerTiming(i.TRIGGERTYPE),
createSql: getTriggerCreateSql(i),
}));
const primaryKeys = primaryKeysResult.rows ?? [];
const primaryKeys =
primaryKeysResult.rows?.map(primaryKey => ({
...primaryKey,
objectId: `tables:${primaryKey.pureName}`,
})) ?? [];
const foreignKeys = foreignKeysResult.rows ?? [];
const foreignKeys =
foreignKeysResult.rows?.map(foreignKey => ({
...foreignKey,
objectId: `tables:${foreignKey.pureName}`,
})) ?? [];
const functions = functionsResults.rows?.map(func => ({
...func,
objectId: `functions:${func.pureName}`,
returnType: functionParametersResults.rows?.filter(
param => param.owningObjectName === func.pureName && param.parameterMode === 'RETURN'
)?.dataType,
@@ -58,6 +69,7 @@ class Analyser extends DatabaseAnalyser {
const procedures = proceduresResults.rows.map(proc => ({
...proc,
objectId: `procedures:${proc.pureName}`,
parameters: procedureParametersResults.rows
?.filter(param => param.owningObjectName === proc.pureName)
.map(param => ({
@@ -69,6 +81,7 @@ class Analyser extends DatabaseAnalyser {
const tables =
tablesResult.rows?.map(table => ({
...table,
objectId: `tables:${table.pureName}`,
columns: columns.filter(column => column.tableName === table.pureName),
primaryKey: DatabaseAnalyser.extractPrimaryKeys(table, primaryKeys),
foreignKeys: DatabaseAnalyser.extractForeignKeys(table, foreignKeys),
@@ -81,6 +94,12 @@ class Analyser extends DatabaseAnalyser {
procedures,
};
}
async _computeSingleObjectId() {
const { typeField, pureName } = this.singleObjectFilter;
console.log('Computing single object ID for', typeField, pureName);
this.singleObjectId = `${typeField}:${pureName}`;
}
}
module.exports = Analyser;