From 9b09472c89a4ca463b2130e5dc08c8040664f8f8 Mon Sep 17 00:00:00 2001 From: "Austin.Duan" Date: Fri, 22 Sep 2023 10:53:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-105428=20fix:=20=E7=A7=BB=E9=99=A4SS?= =?UTF-8?q?H=E4=B8=BB=E6=9C=BA=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/maintain/forms/components/form.jdbc.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 0a78633..a3a2dee 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -1014,7 +1014,6 @@ export class FormJdbc extends BI.Widget { this.form.sshIp = _ref; }, watermark: BI.i18nText('Dec-Dcm_Connection_Form_Host'), - allowBlank: false, value: sshIp, listeners: [ { @@ -1651,7 +1650,7 @@ export class FormJdbc extends BI.Widget { public validation(): boolean { const driver = this.form.driver.validation(); - const sshSet = !this.form.usingSsh.isSelected() || (this.form.sshIp.getValue() !== '' && this.form.sshPort.getValue() !== ''); + const sshSet = !this.form.usingSsh.isSelected() || BI.isNotEmptyString(this.form.sshPort.getValue()); return driver && sshSet; } From f93eb67053357935e887bf1a78f3a1fe754cd1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 19 Oct 2023 14:00:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-99289=20=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=80=82=E9=85=8D=E5=8A=A0=E4=B8=80=E4=B8=AAcatalog?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.provider.ts | 7 ++-- src/modules/app.service.ts | 8 ++++- src/modules/constants/constant.ts | 2 +- .../connection_jdbc/connection_jdbc.ts | 8 ++++- .../maintain/forms/components/form.jdbc.ts | 35 +++++++++++++++++-- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/modules/app.provider.ts b/src/modules/app.provider.ts index 846d138..78a5cbd 100644 --- a/src/modules/app.provider.ts +++ b/src/modules/app.provider.ts @@ -11,18 +11,19 @@ BI.provider('dec.connection.provider.datebase', function () { return { host: result[1], port: result[2] === 'port' ? '' : result[2], - databaseName: result[4] || '', + catalog: result[3], + databaseName: result[4], urlInfo: result[0], }; } // 处理starRocks数据连接负载均衡模式 const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); if (loadBalance){ - const database: string = loadBalance[2]; return { host: '', port: '', - databaseName: database, + catalog: loadBalance[1], + databaseName: loadBalance[2], urlInfo: loadBalance[0], } } diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index af79ad0..d33bb97 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -61,7 +61,7 @@ export function resolveUrlInfo(url: string, database?: string) { } // 拼接url -export function splitUrl(host: string, port: string, database: string, baseUrl: string) { +export function splitUrl(host: string, port: string, catalog: string, database: string, baseUrl: string) { if (baseUrl.startsWith('jdbc:sqlserver')) { return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') .replace('=database', `=${database}`); @@ -75,6 +75,12 @@ export function splitUrl(host: string, port: string, database: string, baseUrl: .replace(':INFORMIXSERVER={server}', ''); } + if (catalog) { + return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') + .replace('default_catalog', catalog) + .replace('database', database) + } + return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') .replace('/database', `/${database}`) .replace(':database', `:${database}`) diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 7b698a0..2e12817 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -722,7 +722,7 @@ export const DATA_BASE_TYPES = [ databaseType: 'starrocks', driver: 'com.mysql.jdbc.Driver', drivers: ['com.mysql.jdbc.Driver'], - url: 'jdbc:mysql://hostname:port/database', + url: 'jdbc:mysql://hostname:port/default_catalog.database', commonly: false, internal: true, type: 'jdbc', diff --git a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts index 817b50d..5a7069d 100644 --- a/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts +++ b/src/modules/pages/connection/connection_jdbc/connection_jdbc.ts @@ -57,7 +57,7 @@ export class ConnectionJdbc extends BI.Widget { hdfs, } = connectionData; const databaseType = getJdbcDatabaseType(database, driver); - const { host, port, databaseName, version } = resolveUrlInfo(url, database); + const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database); this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; const { hgap, vgap } = CONNECTION_LAYOUT; @@ -78,6 +78,12 @@ export class ConnectionJdbc extends BI.Widget { name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver, }, + { + type: FormItem.xtype, + name: 'catalog', + invisible: database !== 'starrocks', + value: catalog, + }, { type: FormItem.xtype, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'), diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index a3a2dee..f8f5d22 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -51,6 +51,7 @@ export class FormJdbc extends BI.Widget { connectionName: null, version: null, driver: null, + catalog: null, database: null, host: null, port: null, @@ -160,7 +161,7 @@ export class FormJdbc extends BI.Widget { } = connectionPoolAttr as ConnectionPoolJDBC; const databaseType = getJdbcDatabaseType(database, driver); this.databaseType = databaseType; - const { host, port, databaseName, version } = resolveUrlInfo(url, database); + const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database); this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; const { hgap, vgap } = CONNECTION_LAYOUT; @@ -262,6 +263,34 @@ export class FormJdbc extends BI.Widget { }, ], }, + // catalog + { + type: FormItem.xtype, + name: 'catalog', + invisible: database !== 'starrocks', + forms: [ + { + type: BI.TextEditor.xtype, + $value: 'database-catalog', + width: EDITOR_WIDTH, + allowBlank: true, + watermark: 'catalog', + value: catalog, + ref: (_ref: any) => { + this.form.catalog = _ref; + }, + listeners: [ + { + eventName: BI.Editor.EVENT_CHANGE, + action: () => { + debugger; + this.onHostPortChange(databaseType); + }, + }, + ], + }, + ], + }, // 数据库名称 { type: FormItem.xtype, @@ -843,6 +872,7 @@ export class FormJdbc extends BI.Widget { action: () => { const urlInfo = resolveUrlInfo(this.form.url.getValue(), database); this.form.host.setValue(urlInfo.host); + this.form.catalog.setValue(urlInfo.catalog); this.form.database.setValue(urlInfo.databaseName); this.form.port.setValue(urlInfo.port); }, @@ -1578,8 +1608,9 @@ export class FormJdbc extends BI.Widget { const selectUrl = BI.get(urls, driver.driver) || url; const host = this.form.host.getValue(); const port = this.form.port.getValue(); + const catalog = this.form.catalog.getValue(); const database = this.form.database.getValue(); - this.form.url.setValue(splitUrl(host, port, database, selectUrl)); + this.form.url.setValue(splitUrl(host, port, catalog, database, selectUrl)); } private onSshTypeChange(sshType) { From 2f42ff94a540c6a44c6c6cf0879632226a2d71a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Thu, 19 Oct 2023 14:05:22 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-99289=20=E5=88=A0=E9=99=A4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=AD=E7=9A=84debugger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/maintain/forms/components/form.jdbc.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index f8f5d22..cb41e3a 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -283,7 +283,6 @@ export class FormJdbc extends BI.Widget { { eventName: BI.Editor.EVENT_CHANGE, action: () => { - debugger; this.onHostPortChange(databaseType); }, }, 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 4/4] =?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: '',