MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / SetField

Method SetField

ent/mutation.go:8967–9048  ·  view source on GitHub ↗

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

(name string, value ent.Value)

Source from the content-addressed store, hash-verified

8965// the field is not defined in the schema, or if the type mismatched the field
8966// type.
8967func (m *OAuthClientMutation) SetField(name string, value ent.Value) error {
8968 switch name {
8969 case oauthclient.FieldCreatedAt:
8970 v, ok := value.(time.Time)
8971 if !ok {
8972 return fmt.Errorf("unexpected type %T for field %s", value, name)
8973 }
8974 m.SetCreatedAt(v)
8975 return nil
8976 case oauthclient.FieldUpdatedAt:
8977 v, ok := value.(time.Time)
8978 if !ok {
8979 return fmt.Errorf("unexpected type %T for field %s", value, name)
8980 }
8981 m.SetUpdatedAt(v)
8982 return nil
8983 case oauthclient.FieldDeletedAt:
8984 v, ok := value.(time.Time)
8985 if !ok {
8986 return fmt.Errorf("unexpected type %T for field %s", value, name)
8987 }
8988 m.SetDeletedAt(v)
8989 return nil
8990 case oauthclient.FieldGUID:
8991 v, ok := value.(string)
8992 if !ok {
8993 return fmt.Errorf("unexpected type %T for field %s", value, name)
8994 }
8995 m.SetGUID(v)
8996 return nil
8997 case oauthclient.FieldSecret:
8998 v, ok := value.(string)
8999 if !ok {
9000 return fmt.Errorf("unexpected type %T for field %s", value, name)
9001 }
9002 m.SetSecret(v)
9003 return nil
9004 case oauthclient.FieldName:
9005 v, ok := value.(string)
9006 if !ok {
9007 return fmt.Errorf("unexpected type %T for field %s", value, name)
9008 }
9009 m.SetName(v)
9010 return nil
9011 case oauthclient.FieldHomepageURL:
9012 v, ok := value.(string)
9013 if !ok {
9014 return fmt.Errorf("unexpected type %T for field %s", value, name)
9015 }
9016 m.SetHomepageURL(v)
9017 return nil
9018 case oauthclient.FieldRedirectUris:
9019 v, ok := value.([]string)
9020 if !ok {
9021 return fmt.Errorf("unexpected type %T for field %s", value, name)
9022 }
9023 m.SetRedirectUris(v)
9024 return nil

Callers

nothing calls this directly

Calls 11

SetCreatedAtMethod · 0.95
SetUpdatedAtMethod · 0.95
SetDeletedAtMethod · 0.95
SetGUIDMethod · 0.95
SetSecretMethod · 0.95
SetNameMethod · 0.95
SetHomepageURLMethod · 0.95
SetRedirectUrisMethod · 0.95
SetScopesMethod · 0.95
SetPropsMethod · 0.95
SetIsEnabledMethod · 0.95

Tested by

no test coverage detected