mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 16:06:01 +00:00
feat: add uniques to firebird
This commit is contained in:
@@ -9,6 +9,7 @@ const functionParameters = require('./functionParameters');
|
||||
const procedures = require('./procedures');
|
||||
const procedureParameters = require('./procedureParameters');
|
||||
const views = require('./views');
|
||||
const uniques = require('./uniques');
|
||||
|
||||
module.exports = {
|
||||
version,
|
||||
@@ -22,4 +23,5 @@ module.exports = {
|
||||
functionParameters,
|
||||
procedures,
|
||||
procedureParameters,
|
||||
uniques,
|
||||
};
|
||||
|
||||
23
plugins/dbgate-plugin-firebird/src/backend/sql/uniques.js
Normal file
23
plugins/dbgate-plugin-firebird/src/backend/sql/uniques.js
Normal file
@@ -0,0 +1,23 @@
|
||||
module.exports = `
|
||||
SELECT
|
||||
TRIM(rc.RDB$CONSTRAINT_NAME) AS "constraintName", -- Name of the constraint
|
||||
TRIM('unique') AS "constraintType", -- Type of the constraint
|
||||
TRIM(rc.RDB$RELATION_NAME) AS "pureName", -- Context: Table the constraint is on
|
||||
|
||||
-- Column specific fields from RDB$INDEX_SEGMENTS for the backing index
|
||||
TRIM(s.RDB$FIELD_NAME) AS "columnName", -- Name of the column in the unique key
|
||||
CASE COALESCE(i.RDB$INDEX_TYPE, 0) -- isDescending: 0 for ASC (default), 1 for DESC for the backing index
|
||||
WHEN 1 THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS "isDescending"
|
||||
FROM
|
||||
RDB$RELATION_CONSTRAINTS rc
|
||||
JOIN
|
||||
-- RDB$INDEX_NAME in RDB$RELATION_CONSTRAINTS is the name of the index that enforces the UNIQUE constraint
|
||||
RDB$INDICES i ON rc.RDB$INDEX_NAME = i.RDB$INDEX_NAME
|
||||
JOIN
|
||||
RDB$INDEX_SEGMENTS s ON i.RDB$INDEX_NAME = s.RDB$INDEX_NAME
|
||||
WHERE
|
||||
rc.RDB$CONSTRAINT_TYPE = 'UNIQUE' -- Filter for UNIQUE constraints
|
||||
AND COALESCE(i.RDB$SYSTEM_FLAG, 0) = 0 -- Typically, backing indexes for user UQ constraints are user-related.
|
||||
`;
|
||||
Reference in New Issue
Block a user