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 2668caad1..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 } @@ -932,13 +935,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}, }