Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions src/common/datasource/db2/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* 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';

// 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: false,
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, IDataSourceModeConfig> = {
[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: '"',
// 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
}
}
};

if (haveOCP()) {
delete items[ConnectType.DB2];
}

export default items;
16 changes: 15 additions & 1 deletion src/common/datasource/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<
Expand Down Expand Up @@ -172,6 +175,15 @@ const _styles = {
dbIcon: {
component: DBDMSvg
}
},
[IDataSourceType.DB2]: {
icon: {
component: DB2Svg,
color: '#0F62FE'
},
dbIcon: {
component: DBDB2Svg
}
}
};

Expand All @@ -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<ConnectType, IDataSourceType> = new Map();
Expand Down Expand Up @@ -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[] {
Expand Down
3 changes: 2 additions & 1 deletion src/constant/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand Down
3 changes: 2 additions & 1 deletion src/d.ts/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ export enum IDataSourceType {
HUAWEI = 'HUAWEI',
AWSS3 = 'AWSS3',
SQL_SERVER = 'SQL_SERVER',
DM = 'DM'
DM = 'DM',
DB2 = 'DB2'
}
4 changes: 3 additions & 1 deletion src/d.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ export enum ConnectionMode {
OB_ORACLE = 'OB_ORACLE',
SQL_SERVER = 'SQL_SERVER',
DM = 'DM',
DB2 = 'DB2',
ALL = 'ALL',
UNKNOWN = 'UNKNOWN'
}
Expand Down Expand Up @@ -3560,7 +3561,8 @@ export enum ConnectType {
OBS = 'OBS',
S3A = 'S3A',
SQL_SERVER = 'SQL_SERVER',
DM = 'DM'
DM = 'DM',
DB2 = 'DB2'
}

export enum DatasourceGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
3 changes: 3 additions & 0 deletions src/svgr/database_db2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/svgr/db2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.