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)
| 13702 | // the field is not defined in the schema, or if the type mismatched the field |
| 13703 | // type. |
| 13704 | func (m *StoragePolicyMutation) SetField(name string, value ent.Value) error { |
| 13705 | switch name { |
| 13706 | case storagepolicy.FieldCreatedAt: |
| 13707 | v, ok := value.(time.Time) |
| 13708 | if !ok { |
| 13709 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13710 | } |
| 13711 | m.SetCreatedAt(v) |
| 13712 | return nil |
| 13713 | case storagepolicy.FieldUpdatedAt: |
| 13714 | v, ok := value.(time.Time) |
| 13715 | if !ok { |
| 13716 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13717 | } |
| 13718 | m.SetUpdatedAt(v) |
| 13719 | return nil |
| 13720 | case storagepolicy.FieldDeletedAt: |
| 13721 | v, ok := value.(time.Time) |
| 13722 | if !ok { |
| 13723 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13724 | } |
| 13725 | m.SetDeletedAt(v) |
| 13726 | return nil |
| 13727 | case storagepolicy.FieldName: |
| 13728 | v, ok := value.(string) |
| 13729 | if !ok { |
| 13730 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13731 | } |
| 13732 | m.SetName(v) |
| 13733 | return nil |
| 13734 | case storagepolicy.FieldType: |
| 13735 | v, ok := value.(string) |
| 13736 | if !ok { |
| 13737 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13738 | } |
| 13739 | m.SetType(v) |
| 13740 | return nil |
| 13741 | case storagepolicy.FieldServer: |
| 13742 | v, ok := value.(string) |
| 13743 | if !ok { |
| 13744 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13745 | } |
| 13746 | m.SetServer(v) |
| 13747 | return nil |
| 13748 | case storagepolicy.FieldBucketName: |
| 13749 | v, ok := value.(string) |
| 13750 | if !ok { |
| 13751 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13752 | } |
| 13753 | m.SetBucketName(v) |
| 13754 | return nil |
| 13755 | case storagepolicy.FieldIsPrivate: |
| 13756 | v, ok := value.(bool) |
| 13757 | if !ok { |
| 13758 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 13759 | } |
| 13760 | m.SetIsPrivate(v) |
| 13761 | return nil |
nothing calls this directly
no test coverage detected