fix(cache): 修复 tableExists 方法以正确检测达梦数据库中的表存在性

- 修改 tableExists 方法,使用 COUNT(*) 查询当前 schema 下的表,避免因用户权限导致的误判
- 更新 ObjToFloat64、ObjToInt64 和 ObjToStr 方法,增加对多种整数和布尔类型的支持
- 在 Row 方法中处理 time.Time 类型,确保与 MySQL 兼容的字符串格式输出
This commit is contained in:
2026-03-20 13:51:52 +08:00
parent 5e2bd765bf
commit a7395b08de
4 changed files with 673 additions and 8 deletions
+12 -5
View File
@@ -8,6 +8,7 @@ import (
"reflect"
"strconv"
"strings"
"time"
. "code.hoteas.com/golang/hotime/common"
)
@@ -546,22 +547,28 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
return nil
}
for j := 0; j < colCount; j++ {
// 统一转小写,兼容DM8等返回大写列名的数据库驱动
colKey := strings.ToLower(strs[j])
val := a[j]
if val == nil {
lis[strs[j]] = nil
lis[colKey] = nil
continue
}
switch v := val.(type) {
case []byte:
lis[strs[j]] = convertBytes(v, categories[j], scales[j])
lis[colKey] = convertBytes(v, categories[j], scales[j])
case float64:
lis[strs[j]] = fixFloatValue(v, categories[j], scales[j])
lis[colKey] = fixFloatValue(v, categories[j], scales[j])
case float32:
lis[strs[j]] = fixFloatValue(float64(v), categories[j], scales[j])
lis[colKey] = fixFloatValue(float64(v), categories[j], scales[j])
case time.Time:
// DM8驱动直接返回time.Time,格式化为MySQL兼容字符串
lis[colKey] = v.Format("2006-01-02 15:04:05")
default:
lis[strs[j]] = val
lis[colKey] = val
}
}
dest = append(dest, lis)
}
if err := resl.Err(); err != nil {