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)
| 16332 | // the field is not defined in the schema, or if the type mismatched the field |
| 16333 | // type. |
| 16334 | func (m *UserMutation) SetField(name string, value ent.Value) error { |
| 16335 | switch name { |
| 16336 | case user.FieldCreatedAt: |
| 16337 | v, ok := value.(time.Time) |
| 16338 | if !ok { |
| 16339 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16340 | } |
| 16341 | m.SetCreatedAt(v) |
| 16342 | return nil |
| 16343 | case user.FieldUpdatedAt: |
| 16344 | v, ok := value.(time.Time) |
| 16345 | if !ok { |
| 16346 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16347 | } |
| 16348 | m.SetUpdatedAt(v) |
| 16349 | return nil |
| 16350 | case user.FieldDeletedAt: |
| 16351 | v, ok := value.(time.Time) |
| 16352 | if !ok { |
| 16353 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16354 | } |
| 16355 | m.SetDeletedAt(v) |
| 16356 | return nil |
| 16357 | case user.FieldEmail: |
| 16358 | v, ok := value.(string) |
| 16359 | if !ok { |
| 16360 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16361 | } |
| 16362 | m.SetEmail(v) |
| 16363 | return nil |
| 16364 | case user.FieldNick: |
| 16365 | v, ok := value.(string) |
| 16366 | if !ok { |
| 16367 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16368 | } |
| 16369 | m.SetNick(v) |
| 16370 | return nil |
| 16371 | case user.FieldPassword: |
| 16372 | v, ok := value.(string) |
| 16373 | if !ok { |
| 16374 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16375 | } |
| 16376 | m.SetPassword(v) |
| 16377 | return nil |
| 16378 | case user.FieldStatus: |
| 16379 | v, ok := value.(user.Status) |
| 16380 | if !ok { |
| 16381 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16382 | } |
| 16383 | m.SetStatus(v) |
| 16384 | return nil |
| 16385 | case user.FieldStorage: |
| 16386 | v, ok := value.(int64) |
| 16387 | if !ok { |
| 16388 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 16389 | } |
| 16390 | m.SetStorage(v) |
| 16391 | return nil |
nothing calls this directly
no test coverage detected