mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-15 02:49:49 +08:00
- 统一 PG-like 数据源字段和索引元数据查询,支持 search_path 可见表 - 兼容 snake_case、布尔别名和字符串唯一索引标记 - 修复 DuckDB main/memory 路径解析,避免误判外部 catalog - 补充前后端回归测试,覆盖可编辑结果定位和元数据重试路径
45 lines
971 B
Go
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
|
|
}
|
|
}
|