diff --git a/internal/apiserver/service/router.go b/internal/apiserver/service/router.go index a2e5cdba..4d85a029 100644 --- a/internal/apiserver/service/router.go +++ b/internal/apiserver/service/router.go @@ -451,6 +451,13 @@ func (s *APIServer) installMiddleware() error { s.echo.Use(middleware.StaticWithConfig(middleware.StaticConfig{ Skipper: middleware.Skipper(func(c echo.Context) bool { + // 必须先跳过 /odc_query,避免 DMS 自身的 static fallback 把 + // `/odc_query/`、`/odc_query/index.html` 等子路径返回为 DMS index.html, + // 导致 ODC SQL 工作台跳转被截获。无尾斜杠的 /odc_query 由 Group route + // 直接走 ProxyConfig 代理到 ODC 8989,本 Skipper 不影响。 + if strings.HasPrefix(c.Request().URL.Path, s.SqlWorkbenchController.SqlWorkbenchService.GetRootUri()) { + return true + } if strings.HasPrefix(c.Request().URL.Path, s.SqlWorkbenchController.CloudbeaverService.CloudbeaverUsecase.GetRootUri()) { return true } diff --git a/internal/sql_workbench/service/sql_workbench_service.go b/internal/sql_workbench/service/sql_workbench_service.go index 300ead12..11435fea 100644 --- a/internal/sql_workbench/service/sql_workbench_service.go +++ b/internal/sql_workbench/service/sql_workbench_service.go @@ -925,13 +925,15 @@ func (sqlWorkbenchService *SqlWorkbenchService) buildUpdateDatasourceRequest(ctx // convertDBType 转换数据库类型 func (sqlWorkbenchService *SqlWorkbenchService) convertDBType(dmsDBType string) string { // 这里需要根据实际的数据库类型映射关系进行转换 - // ODC目前支持的数据源有: OB_MYSQL, OB_ORACLE, ORACLE, MYSQL, ODP_SHARDING_OB_MYSQL, DORIS, POSTGRESQL + // ODC目前支持的数据源有: OB_MYSQL, OB_ORACLE, ORACLE, MYSQL, ODP_SHARDING_OB_MYSQL, DORIS, POSTGRESQL, GAUSSDB // 其余调用创建数据源接口会直接失败 switch dmsDBType { case "MySQL": return "MYSQL" case "PostgreSQL": return "POSTGRESQL" + case "GaussDB": + return "GAUSSDB" case "Oracle": return "ORACLE" case "SQL Server": @@ -963,7 +965,9 @@ func (sqlWorkbenchService *SqlWorkbenchService) SupportDBType(dbType pkgConst.DB dbType == pkgConst.DBTypeTiDB || dbType == pkgConst.DBTypeTDSQLForInnoDB || dbType == pkgConst.DBTypeGoldenDB || - dbType == pkgConst.DBTypePolarDBForMySQL + dbType == pkgConst.DBTypePolarDBForMySQL || + dbType == pkgConst.DBTypeGaussDB || + dbType == pkgConst.DBTypePostgreSQL } // 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 6c65ba0a..40010ff6 100644 --- a/internal/sql_workbench/service/sql_workbench_service_test.go +++ b/internal/sql_workbench/service/sql_workbench_service_test.go @@ -23,6 +23,7 @@ func Test_convertDBType(t *testing.T) { "TDSQL For InnoDB": {input: "TDSQL For InnoDB", expected: "MYSQL"}, "GoldenDB": {input: "GoldenDB", expected: "MYSQL"}, "PolarDB For MySQL": {input: "PolarDB For MySQL", expected: "MYSQL"}, + "GaussDB": {input: "GaussDB", expected: "GAUSSDB"}, "Unknown passthrough": {input: "UnknownDB", expected: "UnknownDB"}, } for name, tc := range cases { @@ -48,9 +49,11 @@ func Test_SupportDBType(t *testing.T) { "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}, + "PostgreSQL supported": {input: pkgConst.DBTypePostgreSQL, expected: true}, "SQL Server unsupported": {input: pkgConst.DBTypeSQLServer, expected: false}, "PolarDB For MySQL supported": {input: pkgConst.DBTypePolarDBForMySQL, expected: true}, + "GaussDB supported": {input: pkgConst.DBTypeGaussDB, expected: true}, + "GaussDBForMySQL unsupported": {input: pkgConst.DBTypeGaussDBForMySQL, expected: false}, } for name, tc := range cases { t.Run(name, func(t *testing.T) { @@ -61,3 +64,15 @@ func Test_SupportDBType(t *testing.T) { }) } } + +func Test_SupportDBType_GaussDB_PG_family_consistency(t *testing.T) { + svc := &SqlWorkbenchService{} + // CR-13: design §1.2 decision-3 locks PG family (PostgreSQL + GaussDB) + // must be whitelisted together; SQL workbench routing assumes the pair. + if got := svc.SupportDBType(pkgConst.DBTypePostgreSQL); !got { + t.Errorf("PostgreSQL must be supported (CR-13 / EARS-1.2)") + } + if got := svc.SupportDBType(pkgConst.DBTypeGaussDB); !got { + t.Errorf("GaussDB must be supported (EARS-1.2 / decision-3)") + } +}