type AppLoginLog struct {
    Id            uint                `gorm:"column:id;" json:"id"`
    JsonInfo      JSONInfo `gorm:"column:json_info" json:"json_info"`
}

type JSONInfo struct {
    Aid         string `json:"aid"`
    Check       bool   `json:"check"`
    UUID        string `json:"uuid"`
}

func (j *JSONInfo) Value() (driver.Value, error) {
    b, err := encoding.GetCodec("json").Marshal(j)
    return string(b), err
}

func (j *JSONInfo) Scan(v interface{}) error {
    return encoding.GetCodec("json").Unmarshal(v.([]byte), j)
}

when the data is empty, return errors gorm.ErrRecordNotFound , but return error is sql: Scan error on column index 16, name \"json_info\": json: cannot unmarshal string into Go struct field JSONInfo.mcc of type int

我的英文不太好,我用汉语在表述一下:

我的查询数据的时候存在了数据为空的情况,正常应该返回 gorm.ErrRecordNotFound, 但是由于我嵌入了一个JSONInfo结构体,本意是希望他能够将json给解析,就报了错,错误为:sql: Scan error on column index 16, name \"json_info\": json: cannot unmarshal string into Go struct field JSONInfo.mcc of type int 但是这种错误不应该是 gorm.ErrRecordNotFound 么,我应该怎么使用它?

感谢大佬 ~

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking