mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 23:06:00 +00:00
feat: basic firebird analyser
This commit is contained in:
43
plugins/dbgate-plugin-firebird/src/backend/sql/columns.js
Normal file
43
plugins/dbgate-plugin-firebird/src/backend/sql/columns.js
Normal file
@@ -0,0 +1,43 @@
|
||||
module.exports = `
|
||||
SELECT DISTINCT
|
||||
CAST(TRIM(rf.rdb$relation_name) AS VARCHAR(255)) AS tableName,
|
||||
CAST(TRIM(rf.rdb$field_name) AS VARCHAR(255)) AS columnName,
|
||||
CASE rf.rdb$null_flag WHEN 1 THEN FALSE ELSE TRUE END AS notNull,
|
||||
CASE
|
||||
WHEN EXISTS (
|
||||
SELECT 1
|
||||
FROM rdb$relation_constraints rc
|
||||
JOIN rdb$index_segments idx ON rc.rdb$index_name = idx.rdb$index_name
|
||||
WHERE rc.rdb$relation_name = rf.rdb$relation_name
|
||||
AND idx.rdb$field_name = rf.rdb$field_name
|
||||
AND rc.rdb$constraint_type = 'PRIMARY KEY'
|
||||
) THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS isPrimaryKey,
|
||||
f.rdb$field_type AS dataTypeCode,
|
||||
f.rdb$field_precision AS numberprecision,
|
||||
f.rdb$field_scale AS scale,
|
||||
f.rdb$field_length AS length,
|
||||
CAST(TRIM(rf.rdb$default_value) AS VARCHAR(255)) AS defaultValue,
|
||||
CAST(TRIM(rf.rdb$description) AS VARCHAR(255)) AS columnComment,
|
||||
CASE
|
||||
WHEN f.rdb$field_type IN (8, 9, 16) AND f.rdb$field_scale < 0 THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS isUnsigned,
|
||||
CAST(TRIM(rf.rdb$field_name) AS VARCHAR(255)) AS pureName,
|
||||
CAST(TRIM(r.rdb$owner_name) AS VARCHAR(255)) AS schemaName
|
||||
FROM
|
||||
rdb$relation_fields rf
|
||||
JOIN
|
||||
rdb$relations r ON rf.rdb$relation_name = r.rdb$relation_name
|
||||
LEFT JOIN
|
||||
rdb$fields f ON rf.rdb$field_source = f.rdb$field_name
|
||||
LEFT JOIN
|
||||
rdb$character_sets cs ON f.rdb$character_set_id = cs.rdb$character_set_id
|
||||
LEFT JOIN
|
||||
rdb$collations co ON f.rdb$collation_id = co.rdb$collation_id
|
||||
WHERE
|
||||
r.rdb$system_flag = 0
|
||||
ORDER BY
|
||||
tableName, rf.rdb$field_position;
|
||||
`;
|
||||
9
plugins/dbgate-plugin-firebird/src/backend/sql/index.js
Normal file
9
plugins/dbgate-plugin-firebird/src/backend/sql/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const version = require('./version');
|
||||
const tables = require('./tables');
|
||||
const columns = require('./columns');
|
||||
|
||||
module.exports = {
|
||||
version,
|
||||
columns,
|
||||
tables,
|
||||
};
|
||||
9
plugins/dbgate-plugin-firebird/src/backend/sql/tables.js
Normal file
9
plugins/dbgate-plugin-firebird/src/backend/sql/tables.js
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = `
|
||||
SELECT
|
||||
TRIM(RDB$RELATION_NAME) AS pureName,
|
||||
RDB$DESCRIPTION AS objectComment,
|
||||
RDB$FORMAT AS objectTypeField
|
||||
FROM RDB$RELATIONS
|
||||
WHERE RDB$SYSTEM_FLAG = 0 -- only user-defined tables
|
||||
ORDER BY pureName;
|
||||
`;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = `SELECT rdb$get_context('SYSTEM', 'ENGINE_VERSION') as version from rdb$database;`;
|
||||
Reference in New Issue
Block a user