Skip to content

fix(sql_workbench): normalize SQL Server audit schema to catalog name#644

Open
LordofAvernus wants to merge 1 commit into
mainfrom
dms/fix-911
Open

fix(sql_workbench): normalize SQL Server audit schema to catalog name#644
LordofAvernus wants to merge 1 commit into
mainfrom
dms/fix-911

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

User description

Summary

  • callSQLEAudit 前对 SQL Server 的 schemaName 做库名归一化:TestDB.dboTestDB
  • 与 CloudBeaver 老路径使用 DefaultCatalog 的行为对齐,避免 SQLE 直连审核将 TestDB.dbo 当作数据库名连库失败

Fixes actiontech/dms-ee#911

Problem

ODC 资源树将 SQL Server 的 database.schema 平铺为节点名(如 TestDB.dbo)。DMS 原样传给 SQLE /v2/sql_auditschema_name,SQLE 将其赋给连接 DSN 的 DatabaseName,导致:

Cannot open database "TestDB.dbo" requested by the login.

Test plan

  • Test_normalizeSQLEAuditSchemaName 覆盖 SQL Server / MySQL / Oracle

Made with Cursor


Description

  • 新增 normalizeSQLEAuditSchemaName 方法归一化 SQL Server schema 名称

  • 在 callSQLEAudit 中调用归一化方法确保传递正确数据库名

  • 新增单元测试覆盖多种数据库类型的归一化逻辑


Diagram Walkthrough

flowchart LR
  A["调用 callSQLEAudit"]
  B["normalizeSQLEAuditSchemaName 函数"]
  C["返回正确的 catalog 名"]
  A -- "调用归一化" --> B
  B -- "返回规范化结果" --> C
Loading

File Walkthrough

Relevant files
Bug fix
sql_workbench_service.go
新增 SQL Server schema 归一化方法及调用更新                                                   

internal/sql_workbench/service/sql_workbench_service.go

  • 新增 normalizeSQLEAuditSchemaName 方法处理 SQL Server schema 字符串
  • 在 callSQLEAudit 中调用归一化方法传递正确数据库名称
+14/-0   
Tests
sql_workbench_service_test.go
添加 SQL Server schema 归一化单元测试                                                         

internal/sql_workbench/service/sql_workbench_service_test.go

  • 添加 Test_normalizeSQLEAuditSchemaName 单元测试验证归一化逻辑
  • 覆盖 SQL Server、MySQL 和 Oracle 等场景
+42/-0   

ODC exposes SQL Server nodes as database.schema (e.g. TestDB.dbo).
SQLE direct audit uses schema_name as the connection database, so pass
only the catalog part to avoid "Cannot open database TestDB.dbo".

Fixes actiontech/dms-ee#911
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

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

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

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.

1 participant