mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-09 07:59:33 +08:00
- 前端连接表单新增额外连接参数入口,支持 URI query 格式录入与解析回填 - MySQL 兼容驱动支持 JDBC 常见参数映射,修复 UTF-8 字符集与 serverTimezone 兼容问题 - 扩展 Oracle、PostgreSQL 兼容、SQL Server、ClickHouse、MongoDB、达梦、TDengine 参数合并 - 按不同驱动通道处理 DSN、URI、Options 与 Settings,避免统一透传导致连接异常 - 修复编辑已保存连接时解析无认证 URI 会清空已有账号密码的问题 - 补充连接参数透传、缓存隔离、DSN 合并与 URI 回填回归测试
58 lines
1.4 KiB
Go
58 lines
1.4 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",
|
|
})
|
|
|
|
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)
|
|
}
|
|
}
|