MCPcopy Create free account
hub / github.com/clouditor/clouditor / Scan

Method Scan

persistence/gorm/serializer.go:205–223  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

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.
205func (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}

Callers

nothing calls this directly

Calls 1

UnmarshalJSONMethod · 0.45

Tested by

no test coverage detected