fix: remove schema from firebird

This commit is contained in:
Pavel
2025-05-15 13:22:01 +02:00
parent 3e0f834796
commit 06055a7c4c
10 changed files with 16 additions and 29 deletions

View File

@@ -26,9 +26,7 @@ class Analyser extends DatabaseAnalyser {
}));
const triggers = triggersResult.rows?.map(i => ({
pureName: i.PURENAME,
tableName: i.TABLENAME,
shcemaName: i.SCHEMANAME,
...i,
eventType: getTriggerEventType(i.TRIGGERTYPE),
triggerTiming: getTriggerTiming(i.TRIGGERTYPE),
}));
@@ -63,9 +61,7 @@ class Analyser extends DatabaseAnalyser {
const tables =
tablesResult.rows?.map(table => ({
...table,
columns: columns.filter(
column => column.tableName === table.pureName && column.schemaName === table.schemaName
),
columns: columns.filter(column => column.tableName === table.pureName),
primaryKey: DatabaseAnalyser.extractPrimaryKeys(table, primaryKeys),
foreignKeys: DatabaseAnalyser.extractForeignKeys(table, foreignKeys),
})) ?? [];

View File

@@ -1,6 +1,5 @@
module.exports = `
SELECT
TRIM(rel.RDB$OWNER_NAME) AS "schemaName",
TRIM(rc_fk.RDB$RELATION_NAME) AS "pureName",
TRIM(rc_fk.RDB$CONSTRAINT_NAME) AS "constraintName",
TRIM(iseg_fk.RDB$FIELD_NAME) AS "columnName",

View File

@@ -1,6 +1,5 @@
module.exports = `
SELECT
TRIM(F.RDB$OWNER_NAME) AS "owningObjectSchemaName", -- Schema of the function this parameter belongs to
TRIM(FA.RDB$FUNCTION_NAME) AS "owningObjectName", -- Name of the function this parameter belongs to
TRIM(FA.RDB$ARGUMENT_NAME) AS "parameterName",
FFLDS.RDB$FIELD_TYPE AS "dataTypeCode", -- SQL data type code from RDB$FIELDS
@@ -15,8 +14,7 @@ SELECT
FA.RDB$ARGUMENT_POSITION AS "position", -- 0-based index for arguments
-- Fields for ParameterInfo.NamedObjectInfo
TRIM(FA.RDB$FUNCTION_NAME) AS "pureName", -- NamedObjectInfo.pureName for the parameter
TRIM(F.RDB$OWNER_NAME) AS "schemaName" -- NamedObjectInfo.schemaName (owner of the function)
TRIM(FA.RDB$FUNCTION_NAME) AS "pureName" -- NamedObjectInfo.pureName for the parameter
FROM
RDB$FUNCTION_ARGUMENTS FA
@@ -27,5 +25,5 @@ JOIN
WHERE
COALESCE(F.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined functions
ORDER BY
"owningObjectSchemaName", "owningObjectName", "position";
"owningObjectName", "position";
`;

View File

@@ -1,7 +1,6 @@
module.exports = `
SELECT
TRIM(F.RDB$FUNCTION_NAME) AS "pureName",
TRIM(F.RDB$OWNER_NAME) AS "schemaName",
TRIM(F.RDB$FUNCTION_NAME) AS "objectId",
TRIM('FUNCTION') AS "objectTypeField",
TRIM(F.RDB$DESCRIPTION) AS "objectComment",
@@ -12,5 +11,5 @@ FROM
WHERE
COALESCE(F.RDB$SYSTEM_FLAG, 0) = 0 -- User-defined functions
ORDER BY
"schemaName", "pureName";
"pureName";
`;

View File

@@ -1,6 +1,5 @@
module.exports = `
SELECT
TRIM(rel.RDB$OWNER_NAME) AS "schemaName",
TRIM(rc.RDB$RELATION_NAME) AS "pureName",
TRIM(rc.RDB$CONSTRAINT_NAME) AS "constraintName",
TRIM(iseg.RDB$FIELD_NAME) AS "columnName",
@@ -22,7 +21,6 @@ WHERE
rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
AND COALESCE(rel.RDB$SYSTEM_FLAG, 0) = 0 -- Typically, you only want user-defined tables
ORDER BY
"schemaName",
"pureName",
"constraintName",
iseg.RDB$FIELD_POSITION;

View File

@@ -1,6 +1,5 @@
module.exports = `
SELECT
TRIM(P.RDB$OWNER_NAME) AS "owningObjectSchemaName", -- Schema of the procedure this parameter belongs to
TRIM(PP.RDB$PROCEDURE_NAME) AS "owningObjectName", -- Name of the procedure this parameter belongs to
TRIM(PP.RDB$PARAMETER_NAME) AS "parameterName", -- ParameterInfo.parameterName
FFLDS.RDB$FIELD_TYPE AS "dataTypeCode", -- SQL data type code from RDB$FIELDS
@@ -16,8 +15,7 @@ SELECT
PP.RDB$PARAMETER_NUMBER AS "position", -- 0-based for IN params, then 0-based for OUT params
-- Fields for ParameterInfo.NamedObjectInfo
TRIM(PP.RDB$PARAMETER_NAME) AS "pureName", -- NamedObjectInfo.pureName for the parameter
TRIM(P.RDB$OWNER_NAME) AS "schemaName" -- NamedObjectInfo.schemaName (owner of the procedure)
TRIM(PP.RDB$PARAMETER_NAME) AS "pureName" -- NamedObjectInfo.pureName for the parameter
FROM
RDB$PROCEDURE_PARAMETERS PP
@@ -28,5 +26,5 @@ JOIN
WHERE
COALESCE(P.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined procedures
ORDER BY
"owningObjectSchemaName", "owningObjectName", PP.RDB$PARAMETER_TYPE, "position"; -- Order by IN(0)/OUT(1) then by position
"owningObjectName", PP.RDB$PARAMETER_TYPE, "position"; -- Order by IN(0)/OUT(1) then by position
`;

View File

@@ -1,7 +1,6 @@
module.exports = `
SELECT
TRIM(P.RDB$PROCEDURE_NAME) AS "pureName",
TRIM(P.RDB$OWNER_NAME) AS "schemaName",
TRIM(P.RDB$PROCEDURE_NAME) AS "objectId", -- Using procedure name as a practical objectId
TRIM('PROCEDURE') AS "objectTypeField",
TRIM(P.RDB$DESCRIPTION) AS "objectComment",
@@ -13,5 +12,5 @@ WHERE
COALESCE(P.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined procedures
AND P.RDB$PROCEDURE_TYPE IS NOT NULL -- Ensure it's a valid procedure type (0, 1, or 2)
ORDER BY
"schemaName", "pureName";
"pureName";
`;

View File

@@ -2,8 +2,7 @@ module.exports = `
SELECT
TRIM(RDB$RELATION_NAME) AS "pureName",
RDB$DESCRIPTION AS "objectComment",
RDB$FORMAT AS "objectTypeField",
TRIM(RDB$OWNER_NAME) AS "schemaName"
RDB$FORMAT AS "objectTypeField"
FROM RDB$RELATIONS
WHERE RDB$SYSTEM_FLAG = 0 -- only user-defined tables
ORDER BY "pureName";

View File

@@ -1,9 +1,8 @@
module.exports = `
SELECT
TRIM(rtr.RDB$TRIGGER_NAME) as PURENAME,
TRIM(rtr.RDB$RELATION_NAME) as TABLENAME,
rtr.RDB$TRIGGER_TYPE as TRIGGERTYPE,
TRIM(rel.RDB$OWNER_NAME) AS SCHEMANAME
TRIM(rtr.RDB$TRIGGER_NAME) as "pureName",
TRIM(rtr.RDB$RELATION_NAME) as "tableName",
rtr.RDB$TRIGGER_TYPE as TRIGGERTYPE
FROM
RDB$TRIGGERS rtr
JOIN RDB$RELATIONS rel ON rtr.RDB$RELATION_NAME = rel.RDB$RELATION_NAME

View File

@@ -5,13 +5,15 @@ const Dumper = require('./Dumper');
const dialect = {
rangeSelect: true,
ilike: true,
defaultSchemaName: 'public',
multipleSchema: true,
multipleSchema: false,
stringEscapeChar: "'",
fallbackDataType: 'varchar',
anonymousPrimaryKey: false,
enableConstraintsPerTable: true,
stringAgg: true,
quoteIdentifier(s) {
return `"${s}"`;
},
createColumn: true,
dropColumn: true,