From e0bf468d23b30b48cba0cc26f268177bc36b589e Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Fri, 8 May 2026 11:13:55 +0000 Subject: [PATCH 1/2] feat(sql_workbench): add GoldenDB datasource type mapping and support check #814 - Add GoldenDB -> MYSQL mapping in convertDBType(), consistent with TDSQL For InnoDB approach (MySQL protocol compatible) - Add DBTypeGoldenDB to SupportDBType() so GoldenDB datasources enter ODC sync and EE provision flows - Add unit test cases for both functions covering GoldenDB --- .../sql_workbench/service/sql_workbench_service.go | 10 +++++++++- .../service/sql_workbench_service_test.go | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/sql_workbench/service/sql_workbench_service.go b/internal/sql_workbench/service/sql_workbench_service.go index 2668caad1..b29eaaaa6 100644 --- a/internal/sql_workbench/service/sql_workbench_service.go +++ b/internal/sql_workbench/service/sql_workbench_service.go @@ -932,13 +932,21 @@ func (sqlWorkbenchService *SqlWorkbenchService) convertDBType(dmsDBType string) return "TIDB" case "TDSQL For InnoDB": return "MYSQL" + case "GoldenDB": + return "MYSQL" default: return dmsDBType } } func (sqlWorkbenchService *SqlWorkbenchService) SupportDBType(dbType pkgConst.DBType) bool { - return dbType == pkgConst.DBTypeMySQL || dbType == pkgConst.DBTypeOracle || dbType == pkgConst.DBTypeOceanBaseMySQL || dbType == pkgConst.DBTypeDM || dbType == pkgConst.DBTypeTiDB || dbType == pkgConst.DBTypeTDSQLForInnoDB + return dbType == pkgConst.DBTypeMySQL || + dbType == pkgConst.DBTypeOracle || + dbType == pkgConst.DBTypeOceanBaseMySQL || + dbType == pkgConst.DBTypeDM || + dbType == pkgConst.DBTypeTiDB || + dbType == pkgConst.DBTypeTDSQLForInnoDB || + dbType == pkgConst.DBTypeGoldenDB } // buildDatabaseUser 当是ob-mysql时需要给账号管理的账号附加租户名集群名等字符: root@oms_mysql#oms_resource_4250 diff --git a/internal/sql_workbench/service/sql_workbench_service_test.go b/internal/sql_workbench/service/sql_workbench_service_test.go index 303243dd7..60d5784b0 100644 --- a/internal/sql_workbench/service/sql_workbench_service_test.go +++ b/internal/sql_workbench/service/sql_workbench_service_test.go @@ -21,6 +21,7 @@ func Test_convertDBType(t *testing.T) { "OB MySQL": {input: "OceanBase For MySQL", expected: "OB_MYSQL"}, "TiDB": {input: "TiDB", expected: "TIDB"}, "TDSQL For InnoDB": {input: "TDSQL For InnoDB", expected: "MYSQL"}, + "GoldenDB": {input: "GoldenDB", expected: "MYSQL"}, "Unknown passthrough": {input: "UnknownDB", expected: "UnknownDB"}, } for name, tc := range cases { @@ -45,6 +46,7 @@ func Test_SupportDBType(t *testing.T) { "OB MySQL supported": {input: pkgConst.DBTypeOceanBaseMySQL, expected: true}, "TiDB supported": {input: pkgConst.DBTypeTiDB, expected: true}, "TDSQL supported": {input: pkgConst.DBTypeTDSQLForInnoDB, expected: true}, + "GoldenDB supported": {input: pkgConst.DBTypeGoldenDB, expected: true}, "PostgreSQL unsupported": {input: pkgConst.DBTypePostgreSQL, expected: false}, "SQL Server unsupported": {input: pkgConst.DBTypeSQLServer, expected: false}, } From be8955ea1eee9de6ae133fbd33145f7d50b7d67e Mon Sep 17 00:00:00 2001 From: actiontech-zihan Date: Fri, 8 May 2026 15:28:14 +0000 Subject: [PATCH 2/2] feat(sql_workbench): add DefaultSchema field to ODC datasource sync requests GoldenDB does not provide the information_schema database that ODC defaults to for MySQL-type connections, causing datasource status to be INACTIVE. Add DefaultSchema field to CreateDatasourceRequest, UpdateDatasourceRequest and datasourceBaseInfo so DMS can explicitly specify a default schema when syncing datasources to ODC. This change is paired with an ODC-side fix that stops hardcoding information_schema as the default schema for all MySQL-dialect types. Refs: actiontech/dms-ee#814 --- internal/sql_workbench/client/sql_workbench_client.go | 4 +++- internal/sql_workbench/service/sql_workbench_service.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/sql_workbench/client/sql_workbench_client.go b/internal/sql_workbench/client/sql_workbench_client.go index c4004af31..082e6b8be 100644 --- a/internal/sql_workbench/client/sql_workbench_client.go +++ b/internal/sql_workbench/client/sql_workbench_client.go @@ -978,9 +978,10 @@ type CreateDatasourceRequest struct { JdbcURLParameters map[string]interface{} `json:"jdbcUrlParameters"` Host string `json:"host"` Port string `json:"port"` + DefaultSchema *string `json:"defaultSchema,omitempty"` } -// UpdateDatasourceRequest 创建数据源请求结构 +// UpdateDatasourceRequest 更新数据源请求结构 type UpdateDatasourceRequest struct { Id int64 `json:"id"` CreatorID *int64 `json:"creatorId"` @@ -997,6 +998,7 @@ type UpdateDatasourceRequest struct { JdbcURLParameters *map[string]interface{} `json:"jdbcUrlParameters"` Host string `json:"host"` Port string `json:"port"` + DefaultSchema *string `json:"defaultSchema,omitempty"` } // DataSourceStatus 数据源状态结构 diff --git a/internal/sql_workbench/service/sql_workbench_service.go b/internal/sql_workbench/service/sql_workbench_service.go index b29eaaaa6..e2ffff1b7 100644 --- a/internal/sql_workbench/service/sql_workbench_service.go +++ b/internal/sql_workbench/service/sql_workbench_service.go @@ -839,6 +839,7 @@ type datasourceBaseInfo struct { Port string ServiceName *string EnvironmentID int64 + DefaultSchema *string } // buildDatasourceBaseInfo 构建数据源基础信息 @@ -885,6 +886,7 @@ func (sqlWorkbenchService *SqlWorkbenchService) buildCreateDatasourceRequest(ctx ServiceName: baseInfo.ServiceName, SSLConfig: client.SSLConfig{Enabled: false}, EnvironmentID: baseInfo.EnvironmentID, + DefaultSchema: baseInfo.DefaultSchema, }, nil } @@ -905,6 +907,7 @@ func (sqlWorkbenchService *SqlWorkbenchService) buildUpdateDatasourceRequest(ctx ServiceName: baseInfo.ServiceName, SSLConfig: client.SSLConfig{Enabled: false}, EnvironmentID: baseInfo.EnvironmentID, + DefaultSchema: baseInfo.DefaultSchema, }, nil }