mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-31 13:39:48 +08:00
- 标识符处理:下沉 Kingbase 引用逻辑,普通小写 schema/table 不再强制双引号包裹 - 表操作修复:修复截断、清空、导入、导出等路径生成异常双引号 SQL - 同步链路修复:统一数据同步、预览、迁移建表中的 Kingbase schema.table 拼接规则 - 自定义驱动兼容:补齐 kingbase8/kingbasees/kingbasev8 别名归一与写入路径处理 - 回归覆盖:新增 ldf_server.andon_events、转义引号、保留字和大小写标识符测试
105 lines
3.1 KiB
Go
105 lines
3.1 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
func TestNormalizeSchemaAndTable_SQLServerKeepsDatabaseAndQualifiedTable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schemaOrDb, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "sqlserver",
|
|
Database: "master",
|
|
}, "biz_db", "dbo.users")
|
|
|
|
if schemaOrDb != "biz_db" {
|
|
t.Fatalf("expected sqlserver first return value as database name, got %q", schemaOrDb)
|
|
}
|
|
if table != "dbo.users" {
|
|
t.Fatalf("expected sqlserver table name keep qualified form, got %q", table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_SQLServerFallbackToConfigDatabase(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schemaOrDb, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "sqlserver",
|
|
Database: "biz_db",
|
|
}, "", "dbo.users")
|
|
|
|
if schemaOrDb != "biz_db" {
|
|
t.Fatalf("expected sqlserver fallback database from config, got %q", schemaOrDb)
|
|
}
|
|
if table != "dbo.users" {
|
|
t.Fatalf("expected sqlserver table name keep qualified form, got %q", table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_PostgresStillSplitsQualifiedName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "postgres",
|
|
}, "demo_db", "public.orders")
|
|
|
|
if schema != "public" || table != "orders" {
|
|
t.Fatalf("expected postgres qualified split to public.orders, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_KingbaseNormalizesEscapedQualifiedName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "kingbase",
|
|
}, "demo_db", `\"Idf_server\".\"mes_bip_wip_finished\"`)
|
|
|
|
if schema != "Idf_server" || table != "mes_bip_wip_finished" {
|
|
t.Fatalf("expected kingbase qualified split to Idf_server.mes_bip_wip_finished, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeRunConfig_OceanBaseOracleKeepsServiceName(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
config := connection.ConnectionConfig{
|
|
Type: "oceanbase",
|
|
Database: "OBORCL",
|
|
OceanBaseProtocol: "oracle",
|
|
}
|
|
runConfig := normalizeRunConfig(config, "SYS")
|
|
|
|
if runConfig.Database != "OBORCL" {
|
|
t.Fatalf("expected OceanBase Oracle service name to stay OBORCL, got %q", runConfig.Database)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSchemaAndTable_OceanBaseOracleUsesSchemaFromDatabaseTree(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTable(connection.ConnectionConfig{
|
|
Type: "oceanbase",
|
|
OceanBaseProtocol: "oracle",
|
|
}, "SYS", "ORDERS")
|
|
|
|
if schema != "SYS" || table != "ORDERS" {
|
|
t.Fatalf("expected OceanBase Oracle schema/table SYS.ORDERS, got %q.%q", schema, table)
|
|
}
|
|
}
|
|
|
|
func TestQuoteTableIdentByType_KingbaseNormalizesQuotedQualifiedTable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
schema, table := normalizeSchemaAndTableByType("kingbase", "", `\"Idf_server\".\"mes_bip_wip_finished\"`)
|
|
if schema != "Idf_server" || table != "mes_bip_wip_finished" {
|
|
t.Fatalf("expected kingbase qualified split to Idf_server.mes_bip_wip_finished, got %q.%q", schema, table)
|
|
}
|
|
|
|
if got := quoteTableIdentByType("kingbase", schema, table); got != `"Idf_server".mes_bip_wip_finished` {
|
|
t.Fatalf("unexpected kingbase table identifier: %s", got)
|
|
}
|
|
}
|