Files
MyGoNavi/internal/db/metadata_value.go
Syngnat 02faa4586b 🐛 fix(metadata): 修复多数据源主键唯一索引识别
- 统一 PG-like 数据源字段和索引元数据查询,支持 search_path 可见表

- 兼容 snake_case、布尔别名和字符串唯一索引标记

- 修复 DuckDB main/memory 路径解析,避免误判外部 catalog

- 补充前后端回归测试,覆盖可编辑结果定位和元数据重试路径
2026-06-04 10:49:16 +08:00

45 lines
971 B
Go

package db
import (
"fmt"
"strings"
)
func parseMetadataBool(value interface{}) bool {
switch val := value.(type) {
case bool:
return val
case int:
return val != 0
case int64:
return val != 0
case float64:
return val != 0
case string:
text := strings.ToLower(strings.TrimSpace(val))
return text == "t" || text == "true" || text == "1" || text == "y" || text == "yes" || text == "unique"
default:
text := strings.ToLower(strings.TrimSpace(fmt.Sprintf("%v", value)))
return text == "t" || text == "true" || text == "1" || text == "y" || text == "yes" || text == "unique"
}
}
func parseMetadataInt(value interface{}) int {
switch val := value.(type) {
case int:
return val
case int64:
return int(val)
case float64:
return int(val)
case string:
var n int
_, _ = fmt.Sscanf(strings.TrimSpace(val), "%d", &n)
return n
default:
var n int
_, _ = fmt.Sscanf(strings.TrimSpace(fmt.Sprintf("%v", value)), "%d", &n)
return n
}
}