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
+55
View File
@@ -214,8 +214,28 @@ func ObjToFloat64(obj interface{}, e ...*Error) float64 {
switch val := obj.(type) {
case int:
v = float64(val)
case int8:
v = float64(val)
case int16:
v = float64(val)
case int32:
v = float64(val)
case int64:
v = float64(val)
case uint:
v = float64(val)
case uint8:
v = float64(val)
case uint16:
v = float64(val)
case uint32:
v = float64(val)
case uint64:
v = float64(val)
case bool:
if val {
v = 1
}
case string:
value, e2 := strconv.ParseFloat(val, 64)
if e2 != nil {
@@ -295,8 +315,28 @@ func ObjToInt64(obj interface{}, e ...*Error) int64 {
switch val := obj.(type) {
case int:
v = int64(val)
case int8:
v = int64(val)
case int16:
v = int64(val)
case int32:
v = int64(val)
case int64:
v = val
case uint:
v = int64(val)
case uint8:
v = int64(val)
case uint16:
v = int64(val)
case uint32:
v = int64(val)
case uint64:
v = int64(val)
case bool:
if val {
v = 1
}
case string:
value, e2 := StrToInt(val)
if e2 != nil {
@@ -375,8 +415,20 @@ func ObjToStr(obj interface{}) string {
switch val := obj.(type) {
case int:
str = strconv.Itoa(val)
case int8:
str = strconv.Itoa(int(val))
case int16:
str = strconv.Itoa(int(val))
case int32:
str = strconv.Itoa(int(val))
case uint8:
str = strconv.Itoa(int(val))
case uint16:
str = strconv.Itoa(int(val))
case uint32:
str = strconv.FormatUint(uint64(val), 10)
case uint64:
str = strconv.FormatUint(val, 10)
case int64:
str = strconv.FormatInt(val, 10)
case []byte:
@@ -389,6 +441,9 @@ func ObjToStr(obj interface{}) string {
str = strconv.FormatFloat(float64(val), 'f', -1, 32)
case bool:
str = strconv.FormatBool(val)
case time.Time:
// DM8等数据库驱动直接返回time.Time,格式化为MySQL兼容的字符串
str = val.Format("2006-01-02 15:04:05")
default:
strbte, err := json.MarshalIndent(obj, "", "\t")
if err == nil {