mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 15:16:00 +00:00
fix: remove schema from firebird
This commit is contained in:
@@ -26,9 +26,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const triggers = triggersResult.rows?.map(i => ({
|
const triggers = triggersResult.rows?.map(i => ({
|
||||||
pureName: i.PURENAME,
|
...i,
|
||||||
tableName: i.TABLENAME,
|
|
||||||
shcemaName: i.SCHEMANAME,
|
|
||||||
eventType: getTriggerEventType(i.TRIGGERTYPE),
|
eventType: getTriggerEventType(i.TRIGGERTYPE),
|
||||||
triggerTiming: getTriggerTiming(i.TRIGGERTYPE),
|
triggerTiming: getTriggerTiming(i.TRIGGERTYPE),
|
||||||
}));
|
}));
|
||||||
@@ -63,9 +61,7 @@ class Analyser extends DatabaseAnalyser {
|
|||||||
const tables =
|
const tables =
|
||||||
tablesResult.rows?.map(table => ({
|
tablesResult.rows?.map(table => ({
|
||||||
...table,
|
...table,
|
||||||
columns: columns.filter(
|
columns: columns.filter(column => column.tableName === table.pureName),
|
||||||
column => column.tableName === table.pureName && column.schemaName === table.schemaName
|
|
||||||
),
|
|
||||||
primaryKey: DatabaseAnalyser.extractPrimaryKeys(table, primaryKeys),
|
primaryKey: DatabaseAnalyser.extractPrimaryKeys(table, primaryKeys),
|
||||||
foreignKeys: DatabaseAnalyser.extractForeignKeys(table, foreignKeys),
|
foreignKeys: DatabaseAnalyser.extractForeignKeys(table, foreignKeys),
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
SELECT
|
||||||
TRIM(rel.RDB$OWNER_NAME) AS "schemaName",
|
|
||||||
TRIM(rc_fk.RDB$RELATION_NAME) AS "pureName",
|
TRIM(rc_fk.RDB$RELATION_NAME) AS "pureName",
|
||||||
TRIM(rc_fk.RDB$CONSTRAINT_NAME) AS "constraintName",
|
TRIM(rc_fk.RDB$CONSTRAINT_NAME) AS "constraintName",
|
||||||
TRIM(iseg_fk.RDB$FIELD_NAME) AS "columnName",
|
TRIM(iseg_fk.RDB$FIELD_NAME) AS "columnName",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
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$FUNCTION_NAME) AS "owningObjectName", -- Name of the function this parameter belongs to
|
||||||
TRIM(FA.RDB$ARGUMENT_NAME) AS "parameterName",
|
TRIM(FA.RDB$ARGUMENT_NAME) AS "parameterName",
|
||||||
FFLDS.RDB$FIELD_TYPE AS "dataTypeCode", -- SQL data type code from RDB$FIELDS
|
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
|
FA.RDB$ARGUMENT_POSITION AS "position", -- 0-based index for arguments
|
||||||
|
|
||||||
-- Fields for ParameterInfo.NamedObjectInfo
|
-- Fields for ParameterInfo.NamedObjectInfo
|
||||||
TRIM(FA.RDB$FUNCTION_NAME) AS "pureName", -- NamedObjectInfo.pureName for the parameter
|
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)
|
|
||||||
|
|
||||||
FROM
|
FROM
|
||||||
RDB$FUNCTION_ARGUMENTS FA
|
RDB$FUNCTION_ARGUMENTS FA
|
||||||
@@ -27,5 +25,5 @@ JOIN
|
|||||||
WHERE
|
WHERE
|
||||||
COALESCE(F.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined functions
|
COALESCE(F.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined functions
|
||||||
ORDER BY
|
ORDER BY
|
||||||
"owningObjectSchemaName", "owningObjectName", "position";
|
"owningObjectName", "position";
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
SELECT
|
||||||
TRIM(F.RDB$FUNCTION_NAME) AS "pureName",
|
TRIM(F.RDB$FUNCTION_NAME) AS "pureName",
|
||||||
TRIM(F.RDB$OWNER_NAME) AS "schemaName",
|
|
||||||
TRIM(F.RDB$FUNCTION_NAME) AS "objectId",
|
TRIM(F.RDB$FUNCTION_NAME) AS "objectId",
|
||||||
TRIM('FUNCTION') AS "objectTypeField",
|
TRIM('FUNCTION') AS "objectTypeField",
|
||||||
TRIM(F.RDB$DESCRIPTION) AS "objectComment",
|
TRIM(F.RDB$DESCRIPTION) AS "objectComment",
|
||||||
@@ -12,5 +11,5 @@ FROM
|
|||||||
WHERE
|
WHERE
|
||||||
COALESCE(F.RDB$SYSTEM_FLAG, 0) = 0 -- User-defined functions
|
COALESCE(F.RDB$SYSTEM_FLAG, 0) = 0 -- User-defined functions
|
||||||
ORDER BY
|
ORDER BY
|
||||||
"schemaName", "pureName";
|
"pureName";
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
SELECT
|
||||||
TRIM(rel.RDB$OWNER_NAME) AS "schemaName",
|
|
||||||
TRIM(rc.RDB$RELATION_NAME) AS "pureName",
|
TRIM(rc.RDB$RELATION_NAME) AS "pureName",
|
||||||
TRIM(rc.RDB$CONSTRAINT_NAME) AS "constraintName",
|
TRIM(rc.RDB$CONSTRAINT_NAME) AS "constraintName",
|
||||||
TRIM(iseg.RDB$FIELD_NAME) AS "columnName",
|
TRIM(iseg.RDB$FIELD_NAME) AS "columnName",
|
||||||
@@ -22,7 +21,6 @@ WHERE
|
|||||||
rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
|
rc.RDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
|
||||||
AND COALESCE(rel.RDB$SYSTEM_FLAG, 0) = 0 -- Typically, you only want user-defined tables
|
AND COALESCE(rel.RDB$SYSTEM_FLAG, 0) = 0 -- Typically, you only want user-defined tables
|
||||||
ORDER BY
|
ORDER BY
|
||||||
"schemaName",
|
|
||||||
"pureName",
|
"pureName",
|
||||||
"constraintName",
|
"constraintName",
|
||||||
iseg.RDB$FIELD_POSITION;
|
iseg.RDB$FIELD_POSITION;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
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$PROCEDURE_NAME) AS "owningObjectName", -- Name of the procedure this parameter belongs to
|
||||||
TRIM(PP.RDB$PARAMETER_NAME) AS "parameterName", -- ParameterInfo.parameterName
|
TRIM(PP.RDB$PARAMETER_NAME) AS "parameterName", -- ParameterInfo.parameterName
|
||||||
FFLDS.RDB$FIELD_TYPE AS "dataTypeCode", -- SQL data type code from RDB$FIELDS
|
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
|
PP.RDB$PARAMETER_NUMBER AS "position", -- 0-based for IN params, then 0-based for OUT params
|
||||||
|
|
||||||
-- Fields for ParameterInfo.NamedObjectInfo
|
-- Fields for ParameterInfo.NamedObjectInfo
|
||||||
TRIM(PP.RDB$PARAMETER_NAME) AS "pureName", -- NamedObjectInfo.pureName for the parameter
|
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)
|
|
||||||
|
|
||||||
FROM
|
FROM
|
||||||
RDB$PROCEDURE_PARAMETERS PP
|
RDB$PROCEDURE_PARAMETERS PP
|
||||||
@@ -28,5 +26,5 @@ JOIN
|
|||||||
WHERE
|
WHERE
|
||||||
COALESCE(P.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined procedures
|
COALESCE(P.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined procedures
|
||||||
ORDER BY
|
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
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
SELECT
|
||||||
TRIM(P.RDB$PROCEDURE_NAME) AS "pureName",
|
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(P.RDB$PROCEDURE_NAME) AS "objectId", -- Using procedure name as a practical objectId
|
||||||
TRIM('PROCEDURE') AS "objectTypeField",
|
TRIM('PROCEDURE') AS "objectTypeField",
|
||||||
TRIM(P.RDB$DESCRIPTION) AS "objectComment",
|
TRIM(P.RDB$DESCRIPTION) AS "objectComment",
|
||||||
@@ -13,5 +12,5 @@ WHERE
|
|||||||
COALESCE(P.RDB$SYSTEM_FLAG, 0) = 0 -- Filter for user-defined procedures
|
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)
|
AND P.RDB$PROCEDURE_TYPE IS NOT NULL -- Ensure it's a valid procedure type (0, 1, or 2)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
"schemaName", "pureName";
|
"pureName";
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ module.exports = `
|
|||||||
SELECT
|
SELECT
|
||||||
TRIM(RDB$RELATION_NAME) AS "pureName",
|
TRIM(RDB$RELATION_NAME) AS "pureName",
|
||||||
RDB$DESCRIPTION AS "objectComment",
|
RDB$DESCRIPTION AS "objectComment",
|
||||||
RDB$FORMAT AS "objectTypeField",
|
RDB$FORMAT AS "objectTypeField"
|
||||||
TRIM(RDB$OWNER_NAME) AS "schemaName"
|
|
||||||
FROM RDB$RELATIONS
|
FROM RDB$RELATIONS
|
||||||
WHERE RDB$SYSTEM_FLAG = 0 -- only user-defined tables
|
WHERE RDB$SYSTEM_FLAG = 0 -- only user-defined tables
|
||||||
ORDER BY "pureName";
|
ORDER BY "pureName";
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
module.exports = `
|
module.exports = `
|
||||||
SELECT
|
SELECT
|
||||||
TRIM(rtr.RDB$TRIGGER_NAME) as PURENAME,
|
TRIM(rtr.RDB$TRIGGER_NAME) as "pureName",
|
||||||
TRIM(rtr.RDB$RELATION_NAME) as TABLENAME,
|
TRIM(rtr.RDB$RELATION_NAME) as "tableName",
|
||||||
rtr.RDB$TRIGGER_TYPE as TRIGGERTYPE,
|
rtr.RDB$TRIGGER_TYPE as TRIGGERTYPE
|
||||||
TRIM(rel.RDB$OWNER_NAME) AS SCHEMANAME
|
|
||||||
FROM
|
FROM
|
||||||
RDB$TRIGGERS rtr
|
RDB$TRIGGERS rtr
|
||||||
JOIN RDB$RELATIONS rel ON rtr.RDB$RELATION_NAME = rel.RDB$RELATION_NAME
|
JOIN RDB$RELATIONS rel ON rtr.RDB$RELATION_NAME = rel.RDB$RELATION_NAME
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ const Dumper = require('./Dumper');
|
|||||||
const dialect = {
|
const dialect = {
|
||||||
rangeSelect: true,
|
rangeSelect: true,
|
||||||
ilike: true,
|
ilike: true,
|
||||||
defaultSchemaName: 'public',
|
multipleSchema: false,
|
||||||
multipleSchema: true,
|
|
||||||
stringEscapeChar: "'",
|
stringEscapeChar: "'",
|
||||||
fallbackDataType: 'varchar',
|
fallbackDataType: 'varchar',
|
||||||
anonymousPrimaryKey: false,
|
anonymousPrimaryKey: false,
|
||||||
enableConstraintsPerTable: true,
|
enableConstraintsPerTable: true,
|
||||||
stringAgg: true,
|
stringAgg: true,
|
||||||
|
quoteIdentifier(s) {
|
||||||
|
return `"${s}"`;
|
||||||
|
},
|
||||||
|
|
||||||
createColumn: true,
|
createColumn: true,
|
||||||
dropColumn: true,
|
dropColumn: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user