mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 20:16:00 +00:00
not start server connection for single-database
This commit is contained in:
@@ -54,6 +54,9 @@ module.exports = {
|
|||||||
if (!connection) {
|
if (!connection) {
|
||||||
throw new Error(`Connection with conid="${conid}" not found`);
|
throw new Error(`Connection with conid="${conid}" not found`);
|
||||||
}
|
}
|
||||||
|
if (connection.singleDatabase) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (connection.passwordMode == 'askPassword' || connection.passwordMode == 'askUser') {
|
if (connection.passwordMode == 'askPassword' || connection.passwordMode == 'askUser') {
|
||||||
throw new MissingCredentialsError({ conid, passwordMode: connection.passwordMode });
|
throw new MissingCredentialsError({ conid, passwordMode: connection.passwordMode });
|
||||||
}
|
}
|
||||||
@@ -142,14 +145,14 @@ module.exports = {
|
|||||||
if (conid == '__model') return [];
|
if (conid == '__model') return [];
|
||||||
testConnectionPermission(conid, req);
|
testConnectionPermission(conid, req);
|
||||||
const opened = await this.ensureOpened(conid);
|
const opened = await this.ensureOpened(conid);
|
||||||
return opened.databases;
|
return opened?.databases ?? [];
|
||||||
},
|
},
|
||||||
|
|
||||||
version_meta: true,
|
version_meta: true,
|
||||||
async version({ conid }, req) {
|
async version({ conid }, req) {
|
||||||
testConnectionPermission(conid, req);
|
testConnectionPermission(conid, req);
|
||||||
const opened = await this.ensureOpened(conid);
|
const opened = await this.ensureOpened(conid);
|
||||||
return opened.version;
|
return opened?.version ?? null;
|
||||||
},
|
},
|
||||||
|
|
||||||
serverStatus_meta: true,
|
serverStatus_meta: true,
|
||||||
@@ -170,6 +173,9 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
this.lastPinged[conid] = new Date().getTime();
|
this.lastPinged[conid] = new Date().getTime();
|
||||||
const opened = await this.ensureOpened(conid);
|
const opened = await this.ensureOpened(conid);
|
||||||
|
if (!opened) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
opened.subprocess.send({ msgtype: 'ping' });
|
opened.subprocess.send({ msgtype: 'ping' });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -194,6 +200,9 @@ module.exports = {
|
|||||||
async sendDatabaseOp({ conid, msgtype, name }, req) {
|
async sendDatabaseOp({ conid, msgtype, name }, req) {
|
||||||
testConnectionPermission(conid, req);
|
testConnectionPermission(conid, req);
|
||||||
const opened = await this.ensureOpened(conid);
|
const opened = await this.ensureOpened(conid);
|
||||||
|
if (!opened) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (opened.connection.isReadOnly) return false;
|
if (opened.connection.isReadOnly) return false;
|
||||||
const res = await this.sendRequest(opened, { msgtype, name });
|
const res = await this.sendRequest(opened, { msgtype, name });
|
||||||
if (res.errorMessage) {
|
if (res.errorMessage) {
|
||||||
@@ -233,6 +242,9 @@ module.exports = {
|
|||||||
async loadDataCore(msgtype, { conid, ...args }, req) {
|
async loadDataCore(msgtype, { conid, ...args }, req) {
|
||||||
testConnectionPermission(conid, req);
|
testConnectionPermission(conid, req);
|
||||||
const opened = await this.ensureOpened(conid);
|
const opened = await this.ensureOpened(conid);
|
||||||
|
if (!opened) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const res = await this.sendRequest(opened, { msgtype, ...args });
|
const res = await this.sendRequest(opened, { msgtype, ...args });
|
||||||
if (res.errorMessage) {
|
if (res.errorMessage) {
|
||||||
console.error(res.errorMessage);
|
console.error(res.errorMessage);
|
||||||
@@ -254,6 +266,9 @@ module.exports = {
|
|||||||
async summaryCommand({ conid, command, row }, req) {
|
async summaryCommand({ conid, command, row }, req) {
|
||||||
testConnectionPermission(conid, req);
|
testConnectionPermission(conid, req);
|
||||||
const opened = await this.ensureOpened(conid);
|
const opened = await this.ensureOpened(conid);
|
||||||
|
if (!opened) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (opened.connection.isReadOnly) return false;
|
if (opened.connection.isReadOnly) return false;
|
||||||
return this.loadDataCore('summaryCommand', { conid, command, row });
|
return this.loadDataCore('summaryCommand', { conid, command, row });
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user