Closed wenjian022 closed 5 months ago
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 ✨
发一下model 结构体,特别是这个自定义类型,以及这个字段的sql定义 @wenjian022
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 ✨
发一下model结构体,特别是这个自定义类型,以及这个字段的sql定义@wenjian022
现在我换了个方式,dll中是 text
type ServerHosts struct {
Prisons []string `gorm:"serializer:json"`
}
之前的,dll中好像是blob, 之后我把他改成了text也不行
type PrisonsList []string
type ServerHosts struct {
Prisons PrisonsList
}
func (t *PrisonsList) Scan(value interface{}) error {
bytesValue, _ := value.([]byte)
return json.Unmarshal(bytesValue, t)
}
func (t PrisonsList) Value() (driver.Value, error) {
return json.Marshal(t)
}
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 ✨
查询代码
gorm 生成的sql
获取到的结果
通过数据库查获取的结果
prisons 字段是自定义类型,我不知道是不是自定义字段导致查不出来的 ,把prisons 条件删了就正常查
数据源是sqlite