(ctx context.Context)
| 181 | } |
| 182 | |
| 183 | func (_u *MetricUpdateOne) sqlSave(ctx context.Context) (_node *Metric, err error) { |
| 184 | _spec := sqlgraph.NewUpdateSpec(metric.Table, metric.Columns, sqlgraph.NewFieldSpec(metric.FieldID, field.TypeInt)) |
| 185 | id, ok := _u.mutation.ID() |
| 186 | if !ok { |
| 187 | return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Metric.id" for update`)} |
| 188 | } |
| 189 | _spec.Node.ID.Value = id |
| 190 | if fields := _u.fields; len(fields) > 0 { |
| 191 | _spec.Node.Columns = make([]string, 0, len(fields)) |
| 192 | _spec.Node.Columns = append(_spec.Node.Columns, metric.FieldID) |
| 193 | for _, f := range fields { |
| 194 | if !metric.ValidColumn(f) { |
| 195 | return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} |
| 196 | } |
| 197 | if f != metric.FieldID { |
| 198 | _spec.Node.Columns = append(_spec.Node.Columns, f) |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | if ps := _u.mutation.predicates; len(ps) > 0 { |
| 203 | _spec.Predicate = func(selector *sql.Selector) { |
| 204 | for i := range ps { |
| 205 | ps[i](selector) |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | if value, ok := _u.mutation.PushedAt(); ok { |
| 210 | _spec.SetField(metric.FieldPushedAt, field.TypeTime, value) |
| 211 | } |
| 212 | if _u.mutation.PushedAtCleared() { |
| 213 | _spec.ClearField(metric.FieldPushedAt, field.TypeTime) |
| 214 | } |
| 215 | _node = &Metric{config: _u.config} |
| 216 | _spec.Assign = _node.assignValues |
| 217 | _spec.ScanValues = _node.scanValues |
| 218 | if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { |
| 219 | if _, ok := err.(*sqlgraph.NotFoundError); ok { |
| 220 | err = &NotFoundError{metric.Label} |
| 221 | } else if sqlgraph.IsConstraintError(err) { |
| 222 | err = &ConstraintError{msg: err.Error(), wrap: err} |
| 223 | } |
| 224 | return nil, err |
| 225 | } |
| 226 | _u.mutation.done = true |
| 227 | return _node, nil |
| 228 | } |
nothing calls this directly
no test coverage detected