mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-01 04:29:33 +08:00
🐛 fix(query-editor): 修复多数据源大查询限流失效
- SQL限流:抽取查询自动限流工具,修复 SELECT 判断大小写不一致导致限制未生效 - 方言适配:按 Oracle/Dameng、SQL Server、MySQL/PostgreSQL 等方言分别注入行数限制 - 自定义驱动:支持 custom 连接根据 driver 解析 Oracle、PostgreSQL、SQL Server 等方言 - MongoDB修复:修正 db.collection.find() 解析边界,并对 find/只读 aggregate 下推 limit - Oracle优化:DSN 增加 PREFETCH_ROWS 和 LOB FETCH 参数,减少大结果集拉取开销 - 测试覆盖:补充 SQL 方言矩阵、MongoDB 限流和 Oracle DSN 参数测试 Refs #424
This commit is contained in:
32
internal/db/oracle_dsn_test.go
Normal file
32
internal/db/oracle_dsn_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,10 @@ func (o *OracleDB) getDSN(config connection.ConnectionConfig) string {
|
||||
q.Set("SSL", "TRUE")
|
||||
q.Set("SSL VERIFY", "FALSE")
|
||||
}
|
||||
// 提高 prefetch 行数,减少大结果集的网络往返次数(默认仅 25 行/次)
|
||||
q.Set("PREFETCH_ROWS", "10000")
|
||||
// LOB 数据延迟加载,避免大 LOB 列影响普通查询性能
|
||||
q.Set("LOB FETCH", "POST")
|
||||
if encoded := q.Encode(); encoded != "" {
|
||||
u.RawQuery = encoded
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user