Scan implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerInterface to indicate how this struct can be loaded from an SQL database field.
(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{})
| 203 | // Scan implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerInterface to indicate how |
| 204 | // this struct can be loaded from an SQL database field. |
| 205 | func (ValueSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error) { |
| 206 | v := new(structpb.Value) |
| 207 | |
| 208 | if dbValue != nil { |
| 209 | switch d := dbValue.(type) { |
| 210 | case []byte: |
| 211 | err = v.UnmarshalJSON(d) |
| 212 | if err != nil { |
| 213 | return err |
| 214 | } |
| 215 | default: |
| 216 | return persistence.ErrUnsupportedType |
| 217 | } |
| 218 | |
| 219 | field.ReflectValueOf(ctx, dst).Set(reflect.ValueOf(v)) |
| 220 | } |
| 221 | |
| 222 | return |
| 223 | } |
nothing calls this directly
no test coverage detected