From 80732fe32b2dc0bd70a18bc269b02034f2c47522 Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Tue, 19 May 2026 11:35:34 +0000 Subject: [PATCH 1/3] feat(odc-client): add DB2 datasource type (ConnectionMode/ConnectType/IDataSourceType + datasource registration + icons + label + resource tree) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - d.ts: add ConnectionMode.DB2 + ConnectType.DB2 + IDataSourceType.DB2 (F-01 / F-02 / F-03, literal "DB2" pinned per compat-RISK-2) - common/datasource/db2: new datasource config patterned after sqlserver, features.sessionManage=true + features.sqlconsole=true (F-04) - common/datasource/index.tsx: register DB2 + _styles + _gruops (F-05) - svgr: add db2.svg + database_db2.svg (F-06) - constant/label: ConnectTypeText[ConnectType.DB2] = 'DB2' hardcoded, no i18n (F-07 per design §3.2 F-S1) - ResourceTree/DatabaseSearchModal/constant: objectTypeConfig[ConnectType.DB2] = mysqlObjectType (F-08, design §3.4) - F-09 (isDb2DataSource util) intentionally not added per design §3.5 Refs: actiontech/dms-ee#839 --- src/common/datasource/db2/index.tsx | 108 ++++++++++++++++++ src/common/datasource/index.tsx | 16 ++- src/constant/label.ts | 3 +- src/d.ts/datasource.ts | 3 +- src/d.ts/index.ts | 4 +- .../DatabaseSearchModal/constant.ts | 1 + src/svgr/database_db2.svg | 3 + src/svgr/db2.svg | 4 + 8 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 src/common/datasource/db2/index.tsx create mode 100644 src/svgr/database_db2.svg create mode 100644 src/svgr/db2.svg diff --git a/src/common/datasource/db2/index.tsx b/src/common/datasource/db2/index.tsx new file mode 100644 index 000000000..beb2231ee --- /dev/null +++ b/src/common/datasource/db2/index.tsx @@ -0,0 +1,108 @@ +/* + * Copyright 2023 OceanBase + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ConnectType, TaskType } from '@/d.ts'; +import { IDataSourceModeConfig } from '../interface'; +import { haveOCP } from '@/util/env'; + +const tableConfig = { + enableAutoIncrement: true, + type2ColumnType: { + id: 'integer', + name: 'varchar', + date: 'date', + time: 'timestamp' + } +}; + +const functionConfig: IDataSourceModeConfig['schema']['func'] = { + params: ['paramName', 'dataType', 'dataLength'], + defaultValue: { + dataLength: 45 + }, + dataNature: true, + sqlSecurity: true, + deterministic: true +}; + +const procedureConfig: IDataSourceModeConfig['schema']['proc'] = { + params: ['paramName', 'paramMode', 'dataType', 'dataLength'], + defaultValue: { + dataLength: 45 + }, + dataNature: true, + sqlSecurity: true, + deterministic: true +}; + +const items: Record = { + [ConnectType.DB2]: { + connection: { + address: { + items: ['ip', 'port', 'catalogName'] + }, + account: true, + sys: false, + ssl: false, + jdbcDoc: 'https://www.ibm.com/docs/en/db2/11.5?topic=java-jdbc-overview', + disableURLParse: true + }, + features: { + task: [TaskType.DATA_ARCHIVE, TaskType.DATA_DELETE], + obclient: false, + recycleBin: false, + plRun: false, + sessionManage: true, + sessionParams: false, + sqlconsole: true, + sqlExplain: false, + groupResourceTree: true, + export: { + fileLimit: false, + snapshot: false + } + }, + schema: { + table: tableConfig, + func: functionConfig, + proc: procedureConfig, + innerSchema: [ + 'SYSCAT', + 'SYSIBM', + 'SYSIBMADM', + 'SYSIBMINTERNAL', + 'SYSIBMTS', + 'SYSFUN', + 'SYSPROC', + 'SYSSTAT', + 'SYSTOOLS', + 'SYSPUBLIC', + 'NULLID' + ] + }, + sql: { + language: 'mysql', + escapeChar: '"', + caseSensitivity: true + } + } +}; + +if (haveOCP()) { + delete items[ConnectType.DB2]; +} + +export default items; diff --git a/src/common/datasource/index.tsx b/src/common/datasource/index.tsx index d2cff939a..7e0a6023b 100644 --- a/src/common/datasource/index.tsx +++ b/src/common/datasource/index.tsx @@ -30,6 +30,7 @@ import DM from './dm'; import Hana from './hana'; import MongoDB from './mongodb'; import Hive from './hive'; +import DB2 from './db2'; import FileSystem from './fileSystem'; import { ReactComponent as OBSvg } from '@/svgr/source_ob.svg'; import { ReactComponent as DBOBSvg } from '@/svgr/database_oceanbase.svg'; @@ -58,6 +59,8 @@ import { ReactComponent as DMSvg } from '@/svgr/dm.svg'; import { ReactComponent as DBDMSvg } from '@/svgr/database_dm.svg'; import { ReactComponent as MongoDBSvg } from '@/svgr/command.svg'; import { ReactComponent as DBMongoDBSvg } from '@/svgr/database.svg'; +import { ReactComponent as DB2Svg } from '@/svgr/db2.svg'; +import { ReactComponent as DBDB2Svg } from '@/svgr/database_db2.svg'; import odc from '@/plugins/odc'; export const _types: Map< @@ -221,6 +224,15 @@ const _styles = { dbIcon: { component: DBMongoDBSvg } + }, + [IDataSourceType.DB2]: { + icon: { + component: DB2Svg, + color: '#0F62FE' + }, + dbIcon: { + component: DBDB2Svg + } } }; @@ -240,7 +252,8 @@ const _gruops = { [IDataSourceType.DM]: DatasourceGroup.OtherDatabase, [IDataSourceType.HANA]: DatasourceGroup.OtherDatabase, [IDataSourceType.MongoDB]: DatasourceGroup.OtherDatabase, - [IDataSourceType.HIVE]: DatasourceGroup.OtherDatabase + [IDataSourceType.HIVE]: DatasourceGroup.OtherDatabase, + [IDataSourceType.DB2]: DatasourceGroup.OtherDatabase }; export const connectType2Ds: Map = new Map(); @@ -303,6 +316,7 @@ function initDatasource() { register(IDataSourceType.HANA, Hana); register(IDataSourceType.MongoDB, MongoDB); register(IDataSourceType.HIVE, Hive); + register(IDataSourceType.DB2, DB2); } function getAllConnectTypes(ds?: IDataSourceType): ConnectType[] { diff --git a/src/constant/label.ts b/src/constant/label.ts index 4380499e0..0c3cb0da7 100644 --- a/src/constant/label.ts +++ b/src/constant/label.ts @@ -151,7 +151,8 @@ export const ConnectTypeText = (type: ConnectType) => { id: 'src.constant.DM_LABEL', defaultMessage: '达梦(DM)' }), - [ConnectType.HANA]: 'SAP HANA' + [ConnectType.HANA]: 'SAP HANA', + [ConnectType.DB2]: 'DB2' }; return textMap?.[type]; }; diff --git a/src/d.ts/datasource.ts b/src/d.ts/datasource.ts index a918187a9..7183b8d7d 100644 --- a/src/d.ts/datasource.ts +++ b/src/d.ts/datasource.ts @@ -60,5 +60,6 @@ export enum IDataSourceType { DM = 'DM', HANA = 'HANA', MongoDB = 'mongodb', - HIVE = 'HIVE' + HIVE = 'HIVE', + DB2 = 'DB2' } diff --git a/src/d.ts/index.ts b/src/d.ts/index.ts index 5801565b9..6c007d069 100644 --- a/src/d.ts/index.ts +++ b/src/d.ts/index.ts @@ -774,6 +774,7 @@ export enum ConnectionMode { SQL_SERVER = 'SQL_SERVER', DM = 'DM', HANA = 'HANA', + DB2 = 'DB2', ALL = 'ALL', UNKNOWN = 'UNKNOWN' } @@ -3568,7 +3569,8 @@ export enum ConnectType { DM = 'DM', HANA = 'HANA', MONGODB = 'MONGODB', - HIVE = 'HIVE' + HIVE = 'HIVE', + DB2 = 'DB2' } export enum DatasourceGroup { diff --git a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts index 59744e85d..e8c075574 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts @@ -90,6 +90,7 @@ export const objectTypeConfig = { [ConnectType.SQL_SERVER]: sqlServerObjectType, [ConnectType.HANA]: hanaObjectType, [ConnectType.HIVE]: [DbObjectType.table, DbObjectType.column], + [ConnectType.DB2]: mysqlObjectType, SEARCH_OBJECT_FROM_ALL_DATABASE: oracleObjectType }; diff --git a/src/svgr/database_db2.svg b/src/svgr/database_db2.svg new file mode 100644 index 000000000..30a44c917 --- /dev/null +++ b/src/svgr/database_db2.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/svgr/db2.svg b/src/svgr/db2.svg new file mode 100644 index 000000000..3372eea19 --- /dev/null +++ b/src/svgr/db2.svg @@ -0,0 +1,4 @@ + + + DB2 + From 0901e55fdcbb11ee18325034e71f413ddcccb8d4 Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Fri, 29 May 2026 10:37:39 +0000 Subject: [PATCH 2/3] fix(odc-client): align DB2 tableConfig with DB2 LUW semantics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - enableAutoIncrement: true -> false (DB2 uses GENERATED ALWAYS AS IDENTITY rather than MySQL AUTO_INCREMENT; the workbench shouldn't surface an "自增" checkbox that the backend cannot round-trip). - sql.caseSensitivity: true -> false (DB2 upper-cases unquoted identifiers automatically — same default as Oracle / HANA; expand_odc_db2.md §10.3 classifies that as caseSensitivity=false). Issue: dms-ee#839 --- src/common/datasource/db2/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/common/datasource/db2/index.tsx b/src/common/datasource/db2/index.tsx index beb2231ee..349259492 100644 --- a/src/common/datasource/db2/index.tsx +++ b/src/common/datasource/db2/index.tsx @@ -18,8 +18,12 @@ import { ConnectType, TaskType } from '@/d.ts'; import { IDataSourceModeConfig } from '../interface'; import { haveOCP } from '@/util/env'; +// fix_report_20260529_100416 issue (Issue dms-ee#839): DB2 LUW expresses identity columns via +// `GENERATED ALWAYS AS IDENTITY` rather than MySQL's AUTO_INCREMENT keyword. Leaving +// enableAutoIncrement=true causes the table designer to surface an "自增" checkbox that the +// backend has no way to round-trip into DB2 grammar — the front-end now hides the affordance. const tableConfig = { - enableAutoIncrement: true, + enableAutoIncrement: false, type2ColumnType: { id: 'integer', name: 'varchar', @@ -96,7 +100,13 @@ const items: Record = { sql: { language: 'mysql', escapeChar: '"', - caseSensitivity: true + // fix_report_20260529_100416 issue (Issue dms-ee#839): DB2 LUW upper-cases unquoted + // identifiers automatically (same default as Oracle / HANA). The expand_odc_db2.md §10.3 + // table classifies that as `caseSensitivity=false`. The previous `true` setting caused the + // workbench's identifier quoter to wrap every column in double quotes on every keystroke, + // breaking the SQL editor auto-complete UX (search for "TEST_ORDERS" failed because the + // ODC index stored "TEST_ORDERS" uppercase while the typed query was lower). + caseSensitivity: false } } }; From 9f97821a916cf9479a80075c279f907881d680ca Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Mon, 1 Jun 2026 03:30:44 +0000 Subject: [PATCH 3/3] fix(odc-client): allow lower-case column names in DB2 table designer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes Issue dms-ee#839 P0-1: every keystroke in the DB2 table designer's column name input was being silently upper-cased, making lower-case column names impossible to enter through the UI. caseSensitivity is consumed only by CaseInput / CaseTextEditor — when false the editor's onChangeCaseWrap calls toUpperCase() on any unquoted input. The previous comment that blamed SQL editor auto-complete was wrong: this flag does not flow into the SQL editor. Aligning with SQL Server (also double-quoted, also caseSensitivity=true): the table designer accepts the user's verbatim input. Users who need to preserve mixed case at the DB layer can still wrap the identifier in "...", which the editor already supports — DB2's server-side upper-casing of unquoted identifiers is unchanged. Related-Issue: https://github.com/actiontech/dms-ee/issues/839 --- src/common/datasource/db2/index.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/common/datasource/db2/index.tsx b/src/common/datasource/db2/index.tsx index 349259492..74f3b0c59 100644 --- a/src/common/datasource/db2/index.tsx +++ b/src/common/datasource/db2/index.tsx @@ -100,13 +100,18 @@ const items: Record = { sql: { language: 'mysql', escapeChar: '"', - // fix_report_20260529_100416 issue (Issue dms-ee#839): DB2 LUW upper-cases unquoted - // identifiers automatically (same default as Oracle / HANA). The expand_odc_db2.md §10.3 - // table classifies that as `caseSensitivity=false`. The previous `true` setting caused the - // workbench's identifier quoter to wrap every column in double quotes on every keystroke, - // breaking the SQL editor auto-complete UX (search for "TEST_ORDERS" failed because the - // ODC index stored "TEST_ORDERS" uppercase while the typed query was lower). - caseSensitivity: false + // fix_report_20260601_031142 (Issue dms-ee#839, P0-1): caseSensitivity drives the + // CaseInput/CaseTextEditor force-upper-case behavior on the table designer. Setting it to + // false made the column-name input mutate "my_col" into "MY_COL" on every keystroke, + // making lower-case column names impossible to enter (DB2 will still upper-case the + // identifier server-side if the user submits without double quotes — that semantic is + // unchanged). Aligning with SQL Server (also `"` quoted, also `true`): the workbench's + // table designer accepts the user's input verbatim; users who need to preserve mixed + // case can wrap the identifier in "..." themselves, which the editor already supports. + // The previous comment blaming SQL-editor auto-complete was incorrect: caseSensitivity + // is only consumed by CaseInput / CaseTextEditor and does not flow into the SQL editor + // completion pipeline. + caseSensitivity: true } } };