Skip to content
Merged
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
4 changes: 3 additions & 1 deletion internal/sql_workbench/client/sql_workbench_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 数据源状态结构
Expand Down
13 changes: 12 additions & 1 deletion internal/sql_workbench/service/sql_workbench_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ type datasourceBaseInfo struct {
Port string
ServiceName *string
EnvironmentID int64
DefaultSchema *string
}

// buildDatasourceBaseInfo 构建数据源基础信息
Expand Down Expand Up @@ -885,6 +886,7 @@ func (sqlWorkbenchService *SqlWorkbenchService) buildCreateDatasourceRequest(ctx
ServiceName: baseInfo.ServiceName,
SSLConfig: client.SSLConfig{Enabled: false},
EnvironmentID: baseInfo.EnvironmentID,
DefaultSchema: baseInfo.DefaultSchema,
}, nil
}

Expand All @@ -905,6 +907,7 @@ func (sqlWorkbenchService *SqlWorkbenchService) buildUpdateDatasourceRequest(ctx
ServiceName: baseInfo.ServiceName,
SSLConfig: client.SSLConfig{Enabled: false},
EnvironmentID: baseInfo.EnvironmentID,
DefaultSchema: baseInfo.DefaultSchema,
}, nil
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions internal/sql_workbench/service/sql_workbench_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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},
}
Expand Down