From a931e29dae6af164580c22dd21697965a04c2c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 31 Oct 2023 18:10:19 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-108103=20Starrocks=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E8=A7=A3=E6=9E=90=E4=B8=8D=E5=8C=85=E5=90=AB?= =?UTF-8?q?catalog=E7=9A=84=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.provider.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/modules/app.provider.ts b/src/modules/app.provider.ts index 78a5cbd..c1b83e2 100644 --- a/src/modules/app.provider.ts +++ b/src/modules/app.provider.ts @@ -6,7 +6,7 @@ BI.provider('dec.connection.provider.datebase', function () { function starRocksResolve(url: string) { // 处理starRocks数据连接常规模式 - const result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i); + let result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i); if (result) { return { host: result[1], @@ -15,10 +15,22 @@ BI.provider('dec.connection.provider.datebase', function () { databaseName: result[4], urlInfo: result[0], }; + } else { + // 兼容老数据库里面没有catalog的情况 + result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([^]+)(.*)/i); + if (result) { + return { + host: result[1], + port: result[2] === 'port' ? '' : result[2], + catalog: '', + databaseName: result[3], + urlInfo: result[0], + }; + } } // 处理starRocks数据连接负载均衡模式 - const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); - if (loadBalance){ + let loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); + if (loadBalance) { return { host: '', port: '', @@ -26,6 +38,18 @@ BI.provider('dec.connection.provider.datebase', function () { databaseName: loadBalance[2], urlInfo: loadBalance[0], } + } else { + // 兼容老数据库里面没有catalog的情况 + loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)([^/]+)/i); + if (loadBalance) { + return { + host: '', + port: '', + catalog: '', + databaseName: loadBalance[1], + urlInfo: loadBalance[0], + } + } } return { host: '',