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)
| 8621 | // the field is not defined in the schema, or if the type mismatched the field |
| 8622 | // type. |
| 8623 | func (m *LockMutation) SetField(name string, value ent.Value) error { |
| 8624 | switch name { |
| 8625 | case lock.FieldName: |
| 8626 | v, ok := value.(string) |
| 8627 | if !ok { |
| 8628 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 8629 | } |
| 8630 | m.SetName(v) |
| 8631 | return nil |
| 8632 | case lock.FieldCreatedAt: |
| 8633 | v, ok := value.(time.Time) |
| 8634 | if !ok { |
| 8635 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 8636 | } |
| 8637 | m.SetCreatedAt(v) |
| 8638 | return nil |
| 8639 | } |
| 8640 | return fmt.Errorf("unknown Lock field %s", name) |
| 8641 | } |
| 8642 | |
| 8643 | // AddedFields returns all numeric fields that were incremented/decremented during |
| 8644 | // this mutation. |
no test coverage detected