(ctx context.Context)
| 862 | } |
| 863 | |
| 864 | func (_u *MachineUpdateOne) sqlSave(ctx context.Context) (_node *Machine, err error) { |
| 865 | if err := _u.check(); err != nil { |
| 866 | return _node, err |
| 867 | } |
| 868 | _spec := sqlgraph.NewUpdateSpec(machine.Table, machine.Columns, sqlgraph.NewFieldSpec(machine.FieldID, field.TypeInt)) |
| 869 | id, ok := _u.mutation.ID() |
| 870 | if !ok { |
| 871 | return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Machine.id" for update`)} |
| 872 | } |
| 873 | _spec.Node.ID.Value = id |
| 874 | if fields := _u.fields; len(fields) > 0 { |
| 875 | _spec.Node.Columns = make([]string, 0, len(fields)) |
| 876 | _spec.Node.Columns = append(_spec.Node.Columns, machine.FieldID) |
| 877 | for _, f := range fields { |
| 878 | if !machine.ValidColumn(f) { |
| 879 | return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} |
| 880 | } |
| 881 | if f != machine.FieldID { |
| 882 | _spec.Node.Columns = append(_spec.Node.Columns, f) |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | if ps := _u.mutation.predicates; len(ps) > 0 { |
| 887 | _spec.Predicate = func(selector *sql.Selector) { |
| 888 | for i := range ps { |
| 889 | ps[i](selector) |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | if value, ok := _u.mutation.UpdatedAt(); ok { |
| 894 | _spec.SetField(machine.FieldUpdatedAt, field.TypeTime, value) |
| 895 | } |
| 896 | if value, ok := _u.mutation.LastPush(); ok { |
| 897 | _spec.SetField(machine.FieldLastPush, field.TypeTime, value) |
| 898 | } |
| 899 | if _u.mutation.LastPushCleared() { |
| 900 | _spec.ClearField(machine.FieldLastPush, field.TypeTime) |
| 901 | } |
| 902 | if value, ok := _u.mutation.LastHeartbeat(); ok { |
| 903 | _spec.SetField(machine.FieldLastHeartbeat, field.TypeTime, value) |
| 904 | } |
| 905 | if _u.mutation.LastHeartbeatCleared() { |
| 906 | _spec.ClearField(machine.FieldLastHeartbeat, field.TypeTime) |
| 907 | } |
| 908 | if value, ok := _u.mutation.Password(); ok { |
| 909 | _spec.SetField(machine.FieldPassword, field.TypeString, value) |
| 910 | } |
| 911 | if value, ok := _u.mutation.IpAddress(); ok { |
| 912 | _spec.SetField(machine.FieldIpAddress, field.TypeString, value) |
| 913 | } |
| 914 | if value, ok := _u.mutation.Scenarios(); ok { |
| 915 | _spec.SetField(machine.FieldScenarios, field.TypeString, value) |
| 916 | } |
| 917 | if _u.mutation.ScenariosCleared() { |
| 918 | _spec.ClearField(machine.FieldScenarios, field.TypeString) |
| 919 | } |
| 920 | if value, ok := _u.mutation.Version(); ok { |
| 921 | _spec.SetField(machine.FieldVersion, field.TypeString, value) |
nothing calls this directly
no test coverage detected