未验证 提交 37421dd5 编写于 作者: 张哲铭 提交者: GitHub

兼容使用pg数据库,contacts字段json格式无法转换的问题 (#868)

上级 6a3a6307
......@@ -12,9 +12,16 @@ type JSONArr json.RawMessage
// 实现 sql.Scanner 接口,Scan 将 value 扫描至 Jsonb
func (j *JSONObj) Scan(value interface{}) error {
// 判断是不是byte类型
bytes, ok := value.([]byte)
if !ok {
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
// 判断是不是string类型
strings, ok := value.(string)
if !ok {
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
}
// string类型转byte[]
bytes = []byte(strings)
}
result := json.RawMessage{}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册