fix: 观测序列与拒绝停机告警读取 ICCID 时显式指定列名
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 1h20m10s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 1h20m10s
GORM 默认把字段 ICCID 映射成 icc_id: - 观测序列设备换卡的本地预期判定读不到当前卡 ICCID,永远判不成立,只能靠调网关重试到上限 - 拒绝停机告警列表 ICCID 一直为空 补列名测试防回归。
This commit is contained in:
29
internal/query/recorddisplay/columns_test.go
Normal file
29
internal/query/recorddisplay/columns_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package recorddisplay
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
// 防回归:不带 column tag 时 GORM 会把 ICCID 读成 icc_id 列。
|
||||
func TestDefaultNamingSplitsICCID(t *testing.T) {
|
||||
type untagged struct{ ICCID string }
|
||||
type tagged struct {
|
||||
ICCID string `gorm:"column:iccid"`
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
v any
|
||||
want string
|
||||
}{{"untagged", &untagged{}, "icc_id"}, {"tagged", &tagged{}, "iccid"}} {
|
||||
s, err := schema.Parse(tc.v, &sync.Map{}, schema.NamingStrategy{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := s.LookUpField("ICCID").DBName; got != tc.want {
|
||||
t.Fatalf("%s: DBName = %q, want %q", tc.name, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user