fix(qa): ISSUE-001 — 修复 executeCount 不一致的 result 访问模式
executeCount 函数混用了 result.List()[0] 和 result[0] 两种访问模式。 改为统一使用 result.List()[0] 遍历列值,并在 int64 类型断言失败时 通过 gfdb 的 Int64() 方法安全获取数值。
This commit is contained in:
@@ -111,14 +111,20 @@ func (e *QueryExecutor) executeCount(ctx context.Context, metadata map[string]in
|
||||
|
||||
var total int64
|
||||
if result.Len() > 0 {
|
||||
for k, v := range result.List()[0] {
|
||||
_ = k
|
||||
firstRow := result.List()[0]
|
||||
// 遍历第一行所有列,找到第一个可解析为 int64 的值作为总数
|
||||
for _, v := range firstRow {
|
||||
if n, ok := v.(int64); ok {
|
||||
total = n
|
||||
} else {
|
||||
total = result[0]["count"].Int64()
|
||||
break
|
||||
}
|
||||
}
|
||||
// 如果遍历未找到 int64 类型值,尝试通过 gfdb 的 Int64 方法获取
|
||||
if total == 0 && len(firstRow) > 0 {
|
||||
for k := range firstRow {
|
||||
total = result[0][k].Int64()
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return total, nil
|
||||
|
||||
Reference in New Issue
Block a user