mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-08 11:31:57 +08:00
🐛 fix(sqlserver): 修正 uniqueidentifier 展示为十六进制字节
- 查询值规整新增 uniqueidentifier 识别并复用 go-mssqldb GUID 格式化 - 避免 SQL Server 查询结果把 GUID 展示为原始 0x 字节串 - 补充 uniqueidentifier 原始字节回归测试并覆盖驱动返回值路径 Fixes #381
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
mssql "github.com/microsoft/go-mssqldb"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -195,6 +197,12 @@ func bytesToDisplayValue(b []byte, databaseTypeName string) interface{} {
|
||||
}
|
||||
|
||||
dbType := strings.ToUpper(strings.TrimSpace(databaseTypeName))
|
||||
if isSQLServerUniqueIdentifierType(dbType) {
|
||||
var guid mssql.UniqueIdentifier
|
||||
if err := guid.Scan(b); err == nil {
|
||||
return guid.String()
|
||||
}
|
||||
}
|
||||
if isBitLikeDBType(dbType) {
|
||||
if u, ok := bytesToUint64(b); ok {
|
||||
// JS number precision is limited; keep large bitmasks as string.
|
||||
@@ -230,6 +238,10 @@ func bytesToReadableString(b []byte) interface{} {
|
||||
return "0x" + hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
func isSQLServerUniqueIdentifierType(typeName string) bool {
|
||||
return typeName == "UNIQUEIDENTIFIER"
|
||||
}
|
||||
|
||||
func isBitLikeDBType(typeName string) bool {
|
||||
if typeName == "" {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user