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)
| 9848 | // the field is not defined in the schema, or if the type mismatched the field |
| 9849 | // type. |
| 9850 | func (m *MachineMutation) SetField(name string, value ent.Value) error { |
| 9851 | switch name { |
| 9852 | case machine.FieldCreatedAt: |
| 9853 | v, ok := value.(time.Time) |
| 9854 | if !ok { |
| 9855 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9856 | } |
| 9857 | m.SetCreatedAt(v) |
| 9858 | return nil |
| 9859 | case machine.FieldUpdatedAt: |
| 9860 | v, ok := value.(time.Time) |
| 9861 | if !ok { |
| 9862 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9863 | } |
| 9864 | m.SetUpdatedAt(v) |
| 9865 | return nil |
| 9866 | case machine.FieldLastPush: |
| 9867 | v, ok := value.(time.Time) |
| 9868 | if !ok { |
| 9869 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9870 | } |
| 9871 | m.SetLastPush(v) |
| 9872 | return nil |
| 9873 | case machine.FieldLastHeartbeat: |
| 9874 | v, ok := value.(time.Time) |
| 9875 | if !ok { |
| 9876 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9877 | } |
| 9878 | m.SetLastHeartbeat(v) |
| 9879 | return nil |
| 9880 | case machine.FieldMachineId: |
| 9881 | v, ok := value.(string) |
| 9882 | if !ok { |
| 9883 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9884 | } |
| 9885 | m.SetMachineId(v) |
| 9886 | return nil |
| 9887 | case machine.FieldPassword: |
| 9888 | v, ok := value.(string) |
| 9889 | if !ok { |
| 9890 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9891 | } |
| 9892 | m.SetPassword(v) |
| 9893 | return nil |
| 9894 | case machine.FieldIpAddress: |
| 9895 | v, ok := value.(string) |
| 9896 | if !ok { |
| 9897 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9898 | } |
| 9899 | m.SetIpAddress(v) |
| 9900 | return nil |
| 9901 | case machine.FieldScenarios: |
| 9902 | v, ok := value.(string) |
| 9903 | if !ok { |
| 9904 | return fmt.Errorf("unexpected type %T for field %s", value, name) |
| 9905 | } |
| 9906 | m.SetScenarios(v) |
| 9907 | return nil |
nothing calls this directly
no test coverage detected