From 3bfa7d6464a2f8fd90c5e26925d2bb821f1b5e9d Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 2 Dec 2019 10:26:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20BI-56355=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B1=BB=E5=9E=8B=E5=92=8C=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E9=83=BD=E4=B8=BA=E7=A9=BA=EF=BC=8C=E5=88=99=E8=AE=A4?= =?UTF-8?q?=E4=B8=BA=E6=98=AF=E5=85=B6=E4=BB=96jdbc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 10 +++++++++- src/modules/app.service.ts | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index 5cea84c..a1c15e8 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -1,4 +1,4 @@ -import { connectionCanEdit, resolveUrlInfo, splitUrl } from '../app.service'; +import { connectionCanEdit, resolveUrlInfo, splitUrl, getJdbcDatabaseType } from '../app.service'; const connection = { connectionId: '', connectionType: '', @@ -12,6 +12,14 @@ const connection = { test('DEC-11030 拼接url', () => { expect(splitUrl('localhost', '22', 'dbname', 'jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual('jdbc:pivotal:greenplum://localhost:22;dbname'); }); +/** + * test_author_alan + */ +test('BI-56355 如果驱动和URL均为空,则为其他jdbc', () => { + expect(getJdbcDatabaseType('', '').databaseType).toEqual('otherJDBC'); + expect(getJdbcDatabaseType('mysql', '').databaseType).toEqual('mysql'); + expect(getJdbcDatabaseType('', 'com.mysql.jdbc.Driver').databaseType).toEqual('mysql'); +}); /** * test_author_alan diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index bcc6268..31e6ff8 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -27,6 +27,9 @@ export function getPluginWidgetEdit(plugin: string) { // 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型 export function getJdbcDatabaseType(database: string, driver: string): DatabaseType { + if (!database && !driver) { + return DATA_BASE_TYPES_OTHER; + } let databaseType = null; // KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型 // DEC-10872 不能过滤other,因为新版数据连接创建的其他jdbc也是other类型,会混淆,需要和后端讨论一个最佳的解决方案。 @@ -56,7 +59,7 @@ export function resolveUrlInfo (url: string) { urlInfo: greenplumUrl[9], }; } - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^\\?]+)(.*)/i); if (result) { return { host: result[5], From e4289b5c6aeb83f2930122e7ab0f5c45ee0631f2 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 2 Dec 2019 10:28:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 2 +- src/modules/app.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index a1c15e8..9ea92be 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -15,7 +15,7 @@ test('DEC-11030 拼接url', () => { /** * test_author_alan */ -test('BI-56355 如果驱动和URL均为空,则为其他jdbc', () => { +test('BI-56355 如果数据库类型和驱动都为空,则为其他jdbc', () => { expect(getJdbcDatabaseType('', '').databaseType).toEqual('otherJDBC'); expect(getJdbcDatabaseType('mysql', '').databaseType).toEqual('mysql'); expect(getJdbcDatabaseType('', 'com.mysql.jdbc.Driver').databaseType).toEqual('mysql'); diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index 31e6ff8..706a0ab 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -59,7 +59,7 @@ export function resolveUrlInfo (url: string) { urlInfo: greenplumUrl[9], }; } - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^\\?]+)(.*)/i); + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); if (result) { return { host: result[5], From eb68523149d233f30fe9b747a43bcb964f0910d2 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 2 Dec 2019 10:29:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index 706a0ab..fc18f77 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -32,7 +32,6 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT } let databaseType = null; // KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型 - // DEC-10872 不能过滤other,因为新版数据连接创建的其他jdbc也是other类型,会混淆,需要和后端讨论一个最佳的解决方案。 if (database && database !== 'other' && DATA_BASE_TYPES.some(item => item.databaseType === database)) { databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database); } else {