From 9870ccd49348c8e0768a6c604a2551e9a84590f8 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 547364d07..11fdb7b4a 100644 --- a/src/common/datasource/index.tsx +++ b/src/common/datasource/index.tsx @@ -26,6 +26,7 @@ import Doris from './doris'; import TiDB from './tidb'; import PG from './pg'; import DM from './dm'; +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'; @@ -52,6 +53,8 @@ import { ReactComponent as DBSqlServerSvg } from '@/svgr/database_sqlserver.svg' import { ReactComponent as SqlServerSvg } from '@/svgr/sqlserver.svg'; import { ReactComponent as DMSvg } from '@/svgr/dm.svg'; import { ReactComponent as DBDMSvg } from '@/svgr/database_dm.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< @@ -172,6 +175,15 @@ const _styles = { dbIcon: { component: DBDMSvg } + }, + [IDataSourceType.DB2]: { + icon: { + component: DB2Svg, + color: '#0F62FE' + }, + dbIcon: { + component: DBDB2Svg + } } }; @@ -187,7 +199,8 @@ const _gruops = { [IDataSourceType.HUAWEI]: DatasourceGroup.FileSystem, [IDataSourceType.QCLOUD]: DatasourceGroup.FileSystem, [IDataSourceType.SQL_SERVER]: DatasourceGroup.OtherDatabase, - [IDataSourceType.DM]: DatasourceGroup.OtherDatabase + [IDataSourceType.DM]: DatasourceGroup.OtherDatabase, + [IDataSourceType.DB2]: DatasourceGroup.OtherDatabase }; export const connectType2Ds: Map = new Map(); @@ -246,6 +259,7 @@ function initDatasource() { register(IDataSourceType.QCLOUD, FileSystem.QCLOUD); register(IDataSourceType.SQL_SERVER, SqlServer); register(IDataSourceType.DM, DM); + register(IDataSourceType.DB2, DB2); } function getAllConnectTypes(ds?: IDataSourceType): ConnectType[] { diff --git a/src/constant/label.ts b/src/constant/label.ts index adf38797f..d7e29fbb0 100644 --- a/src/constant/label.ts +++ b/src/constant/label.ts @@ -150,7 +150,8 @@ export const ConnectTypeText = (type: ConnectType) => { [ConnectType.DM]: formatMessage({ id: 'src.constant.DM_LABEL', defaultMessage: '达梦(DM)' - }) + }), + [ConnectType.DB2]: 'DB2' }; return textMap?.[type]; }; diff --git a/src/d.ts/datasource.ts b/src/d.ts/datasource.ts index 6e704930d..f655b9191 100644 --- a/src/d.ts/datasource.ts +++ b/src/d.ts/datasource.ts @@ -56,5 +56,6 @@ export enum IDataSourceType { HUAWEI = 'HUAWEI', AWSS3 = 'AWSS3', SQL_SERVER = 'SQL_SERVER', - DM = 'DM' + DM = 'DM', + DB2 = 'DB2' } diff --git a/src/d.ts/index.ts b/src/d.ts/index.ts index 610c03008..0c69eee3c 100644 --- a/src/d.ts/index.ts +++ b/src/d.ts/index.ts @@ -771,6 +771,7 @@ export enum ConnectionMode { OB_ORACLE = 'OB_ORACLE', SQL_SERVER = 'SQL_SERVER', DM = 'DM', + DB2 = 'DB2', ALL = 'ALL', UNKNOWN = 'UNKNOWN' } @@ -3560,7 +3561,8 @@ export enum ConnectType { OBS = 'OBS', S3A = 'S3A', SQL_SERVER = 'SQL_SERVER', - DM = 'DM' + DM = 'DM', + 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 33e969d1e..cbf485ee7 100644 --- a/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts +++ b/src/page/Workspace/SideBar/ResourceTree/DatabaseSearchModal/constant.ts @@ -70,6 +70,7 @@ export const objectTypeConfig = { [ConnectType.OB_ORACLE]: oracleObjectType, [ConnectType.ORACLE]: oracleObjectType, [ConnectType.SQL_SERVER]: sqlServerObjectType, + [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 dc86a0b6863e11b3d7227730b6865cc01f7d21d2 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 b5c95cf24cecfeb40918e84d3a379421eede10b1 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 } } };