处理 text NULL 字段
This commit is contained in:
@@ -87,6 +87,11 @@ type TextList []struct {
|
||||
}
|
||||
|
||||
func (a *TextList) Scan(value interface{}) error {
|
||||
// 如果数据库中的值为NULL,则返回nil
|
||||
if value == nil || len(value.([]byte)) == 0 {
|
||||
*a = TextList{}
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(value.([]byte), a)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user