File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -35,16 +35,20 @@ func (j *JSON) Scan(value interface{}) error {
3535 return nil
3636 }
3737 var bytes []byte
38- switch v := value .(type ) {
39- case []byte :
40- if len (v ) > 0 {
41- bytes = make ([]byte , len (v ))
42- copy (bytes , v )
38+ if s , ok := value .(fmt.Stringer ); ok {
39+ bytes = []byte (s .String ())
40+ } else {
41+ switch v := value .(type ) {
42+ case []byte :
43+ if len (v ) > 0 {
44+ bytes = make ([]byte , len (v ))
45+ copy (bytes , v )
46+ }
47+ case string :
48+ bytes = []byte (v )
49+ default :
50+ return errors .New (fmt .Sprint ("Failed to unmarshal JSONB value:" , value ))
4351 }
44- case string :
45- bytes = []byte (v )
46- default :
47- return errors .New (fmt .Sprint ("Failed to unmarshal JSONB value:" , value ))
4852 }
4953
5054 result := json .RawMessage (bytes )
You can’t perform that action at this time.
0 commit comments