fix(Firebird SQL): error "Cannot read properties of null" connecting to some databases, fixes #708

This commit is contained in:
Fabio Di Stasio 2023-11-09 18:49:56 +01:00
parent e14302bdc0
commit 186fc18363
2 changed files with 19 additions and 15 deletions

View File

@ -118,6 +118,10 @@ export class FirebirdSQLClient extends BaseClient {
return null; return null;
} }
getDatabases (): null[] {
return [];
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
async getStructure (_schemas: Set<string>) { async getStructure (_schemas: Set<string>) {
interface TableResult { interface TableResult {
@ -157,10 +161,10 @@ export class FirebirdSQLClient extends BaseClient {
const { rows: tables } = await this.raw<antares.QueryResult<TableResult>>(` const { rows: tables } = await this.raw<antares.QueryResult<TableResult>>(`
SELECT SELECT
rdb$relation_name AS name, rdb$relation_name AS NAME,
rdb$format AS format, rdb$format AS FORMAT,
rdb$description AS description, rdb$description AS DESCRIPTION,
'table' AS type 'table' AS TYPE
FROM RDB$RELATIONS a FROM RDB$RELATIONS a
WHERE COALESCE(RDB$SYSTEM_FLAG, 0) = 0 WHERE COALESCE(RDB$SYSTEM_FLAG, 0) = 0
AND RDB$RELATION_TYPE = 0 AND RDB$RELATION_TYPE = 0
@ -168,8 +172,8 @@ export class FirebirdSQLClient extends BaseClient {
const { rows: views } = await this.raw<antares.QueryResult<TableResult>>(` const { rows: views } = await this.raw<antares.QueryResult<TableResult>>(`
SELECT SELECT
DISTINCT RDB$VIEW_NAME AS name, DISTINCT RDB$VIEW_NAME AS NAME,
'view' AS type 'view' AS TYPE
FROM RDB$VIEW_RELATIONS FROM RDB$VIEW_RELATIONS
`); `);
@ -177,9 +181,9 @@ export class FirebirdSQLClient extends BaseClient {
const { rows: triggers } = await this.raw<antares.QueryResult<TriggersResult>>(` const { rows: triggers } = await this.raw<antares.QueryResult<TriggersResult>>(`
SELECT SELECT
RDB$TRIGGER_NAME as name, RDB$TRIGGER_NAME as NAME,
RDB$RELATION_NAME as relation, RDB$RELATION_NAME as RELATION,
RDB$TRIGGER_SOURCE as source RDB$TRIGGER_SOURCE as SOURCE
FROM RDB$TRIGGERS FROM RDB$TRIGGERS
WHERE RDB$SYSTEM_FLAG=0 WHERE RDB$SYSTEM_FLAG=0
ORDER BY RDB$TRIGGER_NAME; ORDER BY RDB$TRIGGER_NAME;
@ -208,8 +212,8 @@ export class FirebirdSQLClient extends BaseClient {
schemaSize += tableSize; schemaSize += tableSize;
return { return {
name: table.NAME.trim(), name: table.NAME?.trim(),
type: table.TYPE.trim(), type: table.TYPE?.trim(),
rows: false, rows: false,
size: false size: false
}; };
@ -218,8 +222,8 @@ export class FirebirdSQLClient extends BaseClient {
// TRIGGERS // TRIGGERS
const remappedTriggers = triggersArr.map(trigger => { const remappedTriggers = triggersArr.map(trigger => {
return { return {
name: trigger.NAME.trim(), name: trigger.NAME?.trim(),
table: trigger.RELATION.trim(), table: trigger.RELATION?.trim(),
statement: trigger.SOURCE statement: trigger.SOURCE
}; };
}); });
@ -227,7 +231,7 @@ export class FirebirdSQLClient extends BaseClient {
// PROCEDURES // PROCEDURES
const remappedProcedures = proceduresArr.map(procedure => { const remappedProcedures = proceduresArr.map(procedure => {
return { return {
name: procedure.NAME.trim(), name: procedure.NAME?.trim(),
definer: procedure.DEFINER, definer: procedure.DEFINER,
comment: procedure.COMMENT?.trim() comment: procedure.COMMENT?.trim()
}; };

View File

@ -11,7 +11,7 @@
> >
<div class="workspace-explorebar-header"> <div class="workspace-explorebar-header">
<div <div
v-if="customizations.database" v-if="customizations.database && databases.length"
class="workspace-explorebar-database-switch" class="workspace-explorebar-database-switch"
:title="t('database.switchDatabase')" :title="t('database.switchDatabase')"
> >