From 37421dd56ad8b7293968086dd3be153f292b6696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Tue, 15 Feb 2022 17:58:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=BD=BF=E7=94=A8pg=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=EF=BC=8Ccontacts=E5=AD=97=E6=AE=B5json?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=97=A0=E6=B3=95=E8=BD=AC=E6=8D=A2=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#868)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pkg/ormx/types.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pkg/ormx/types.go b/src/pkg/ormx/types.go index 51790b6f..6e1d2631 100644 --- a/src/pkg/ormx/types.go +++ b/src/pkg/ormx/types.go @@ -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{}