Skip to content

feat: support Redis SQL workbench datasource #873#639

Merged
Seechi-Yolo merged 2 commits into
mainfrom
dev/redis-plugin-873
Jun 12, 2026
Merged

feat: support Redis SQL workbench datasource #873#639
Seechi-Yolo merged 2 commits into
mainfrom
dev/redis-plugin-873

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add DBTypeRedis and ParseDBType("Redis") in DMS CE.
  • Map Redis datasources to ODC REDIS with defaultSchema and jdbcUrlParameters for SQL workbench sync.
  • Trim Redis datasource additional params to default_database only (#873).

Related

Test plan

  • go vet ./internal/dms/pkg/constant/... ./internal/sql_workbench/service/...
  • DMS driver options returns Redis with only default_database
  • DMS v2 creates Redis datasource; connection test is_connectable=true (sqle)
  • DMS /odc_query/ syncs datasource to ODC; ODC Redis API smoke PING/SET/GET/SCAN passed

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 29b7571)

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
增加 nil 检查

建议在调用 dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam) 后增加 nil
检查,以防止返回值为 nil 时调用 .String() 导致 panic。这一改动能提升代码的健壮性,避免潜在的 nil 指针解引用问题。

internal/sql_workbench/service/sql_workbench_service.go [1061-1071]

 func buildRedisDatasourceOptions(dbService *biz.DBService) (*string, interface{}, map[string]interface{}) {
-	defaultDatabase := dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam).String()
-	if defaultDatabase == "" {
-		return nil, nil, nil
-	}
-	defaultSchema := &defaultDatabase
-	jdbcParams := map[string]interface{}{
-		"defaultDatabase": defaultDatabase,
-	}
-	return defaultSchema, nil, jdbcParams
+    param := dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam)
+    if param == nil {
+        return nil, nil, nil
+    }
+    defaultDatabase := param.String()
+    if defaultDatabase == "" {
+        return nil, nil, nil
+    }
+    defaultSchema := &defaultDatabase
+    jdbcParams := map[string]interface{}{
+        "defaultDatabase": defaultDatabase,
+    }
+    return defaultSchema, nil, jdbcParams
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a potential nil dereference issue when calling .String() on the result of dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam). By adding a nil-check, it enhances the robustness of the function, and the improved code accurately reflects this change.

Medium

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 29b7571

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
增加 nil 检查

建议在调用 dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam) 后增加 nil
检查,以防止返回值为 nil 时调用 .String() 导致 panic。这一改动能提升代码的健壮性,避免潜在的 nil 指针解引用问题。

internal/sql_workbench/service/sql_workbench_service.go [1061-1071]

 func buildRedisDatasourceOptions(dbService *biz.DBService) (*string, interface{}, map[string]interface{}) {
-	defaultDatabase := dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam).String()
-	if defaultDatabase == "" {
-		return nil, nil, nil
-	}
-	defaultSchema := &defaultDatabase
-	jdbcParams := map[string]interface{}{
-		"defaultDatabase": defaultDatabase,
-	}
-	return defaultSchema, nil, jdbcParams
+    param := dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam)
+    if param == nil {
+        return nil, nil, nil
+    }
+    defaultDatabase := param.String()
+    if defaultDatabase == "" {
+        return nil, nil, nil
+    }
+    defaultSchema := &defaultDatabase
+    jdbcParams := map[string]interface{}{
+        "defaultDatabase": defaultDatabase,
+    }
+    return defaultSchema, nil, jdbcParams
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a potential nil dereference issue when calling .String() on the result of dbService.AdditionalParams.GetParam(redisDefaultDatabaseParam). By adding a nil-check, it enhances the robustness of the function, and the improved code accurately reflects this change.

Medium

@Seechi-Yolo Seechi-Yolo merged commit 6978015 into main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants