mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-04 21:49:36 +08:00
- MySQL 兼容 JDBC 参数映射并丢弃 allowPublicKeyRetrieval 等无效参数 - 为 PostgreSQL 系、SQL Server、Oracle、达梦、TDengine 接入驱动参数白名单 - 补充连接参数归一化、别名映射和未知参数过滤回归测试
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package db
|
|
|
|
import (
|
|
"net/url"
|
|
"testing"
|
|
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
func TestOracleGetDSNIncludesQueryPerformanceOptions(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
dsn := (&OracleDB{}).getDSN(connection.ConnectionConfig{
|
|
Host: "db.example.com",
|
|
Port: 1521,
|
|
User: "scott",
|
|
Password: "tiger",
|
|
Database: "ORCLPDB1",
|
|
})
|
|
|
|
parsed, err := url.Parse(dsn)
|
|
if err != nil {
|
|
t.Fatalf("解析 Oracle DSN 失败: %v", err)
|
|
}
|
|
query := parsed.Query()
|
|
if got := query.Get("PREFETCH_ROWS"); got != "10000" {
|
|
t.Fatalf("PREFETCH_ROWS = %q, want 10000", got)
|
|
}
|
|
if got := query.Get("LOB FETCH"); got != "POST" {
|
|
t.Fatalf("LOB FETCH = %q, want POST", got)
|
|
}
|
|
}
|
|
|
|
func TestOracleGetDSNMergesConnectionParams(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
dsn := (&OracleDB{}).getDSN(connection.ConnectionConfig{
|
|
Host: "db.example.com",
|
|
Port: 1521,
|
|
User: "scott",
|
|
Password: "tiger",
|
|
Database: "ORCLPDB1",
|
|
ConnectionParams: "PREFETCH_ROWS=5000&TRACE FILE=/tmp/go-ora.trc&connect_timeout=10&FAILOVER=3&unknown=bad",
|
|
})
|
|
|
|
parsed, err := url.Parse(dsn)
|
|
if err != nil {
|
|
t.Fatalf("解析 Oracle DSN 失败: %v", err)
|
|
}
|
|
query := parsed.Query()
|
|
if got := query.Get("PREFETCH_ROWS"); got != "5000" {
|
|
t.Fatalf("PREFETCH_ROWS = %q, want 5000", got)
|
|
}
|
|
if got := query.Get("TRACE FILE"); got != "/tmp/go-ora.trc" {
|
|
t.Fatalf("TRACE FILE = %q, want /tmp/go-ora.trc", got)
|
|
}
|
|
if got := query.Get("CONNECT TIMEOUT"); got != "10" {
|
|
t.Fatalf("CONNECT TIMEOUT = %q, want 10", got)
|
|
}
|
|
if got := query.Get("FAILOVER"); got != "" {
|
|
t.Fatalf("FAILOVER should be filtered because go-ora no longer supports it, got %q", got)
|
|
}
|
|
if got := query.Get("unknown"); got != "" {
|
|
t.Fatalf("unknown should be filtered, got %q", got)
|
|
}
|
|
}
|