From 88cdd2fcbf8ae9f634ff7ac64d712cbdd3c15534 Mon Sep 17 00:00:00 2001 From: "SPRINX0\\prochazka" Date: Thu, 24 Apr 2025 15:10:18 +0200 Subject: [PATCH] not start server connection for single-database --- .../api/src/controllers/serverConnections.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/api/src/controllers/serverConnections.js b/packages/api/src/controllers/serverConnections.js index 61dfe6a82..d9a065bd9 100644 --- a/packages/api/src/controllers/serverConnections.js +++ b/packages/api/src/controllers/serverConnections.js @@ -54,6 +54,9 @@ module.exports = { if (!connection) { throw new Error(`Connection with conid="${conid}" not found`); } + if (connection.singleDatabase) { + return null; + } if (connection.passwordMode == 'askPassword' || connection.passwordMode == 'askUser') { throw new MissingCredentialsError({ conid, passwordMode: connection.passwordMode }); } @@ -142,14 +145,14 @@ module.exports = { if (conid == '__model') return []; testConnectionPermission(conid, req); const opened = await this.ensureOpened(conid); - return opened.databases; + return opened?.databases ?? []; }, version_meta: true, async version({ conid }, req) { testConnectionPermission(conid, req); const opened = await this.ensureOpened(conid); - return opened.version; + return opened?.version ?? null; }, serverStatus_meta: true, @@ -170,6 +173,9 @@ module.exports = { } this.lastPinged[conid] = new Date().getTime(); const opened = await this.ensureOpened(conid); + if (!opened) { + return Promise.resolve(); + } try { opened.subprocess.send({ msgtype: 'ping' }); } catch (err) { @@ -194,6 +200,9 @@ module.exports = { async sendDatabaseOp({ conid, msgtype, name }, req) { testConnectionPermission(conid, req); const opened = await this.ensureOpened(conid); + if (!opened) { + return null; + } if (opened.connection.isReadOnly) return false; const res = await this.sendRequest(opened, { msgtype, name }); if (res.errorMessage) { @@ -233,6 +242,9 @@ module.exports = { async loadDataCore(msgtype, { conid, ...args }, req) { testConnectionPermission(conid, req); const opened = await this.ensureOpened(conid); + if (!opened) { + return null; + } const res = await this.sendRequest(opened, { msgtype, ...args }); if (res.errorMessage) { console.error(res.errorMessage); @@ -254,6 +266,9 @@ module.exports = { async summaryCommand({ conid, command, row }, req) { testConnectionPermission(conid, req); const opened = await this.ensureOpened(conid); + if (!opened) { + return null; + } if (opened.connection.isReadOnly) return false; return this.loadDataCore('summaryCommand', { conid, command, row }); },