(ctx context.Context)
| 303 | } |
| 304 | |
| 305 | func (suo *SettingUpdateOne) sqlSave(ctx context.Context) (_node *Setting, err error) { |
| 306 | _spec := sqlgraph.NewUpdateSpec(setting.Table, setting.Columns, sqlgraph.NewFieldSpec(setting.FieldID, field.TypeInt)) |
| 307 | id, ok := suo.mutation.ID() |
| 308 | if !ok { |
| 309 | return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Setting.id" for update`)} |
| 310 | } |
| 311 | _spec.Node.ID.Value = id |
| 312 | if fields := suo.fields; len(fields) > 0 { |
| 313 | _spec.Node.Columns = make([]string, 0, len(fields)) |
| 314 | _spec.Node.Columns = append(_spec.Node.Columns, setting.FieldID) |
| 315 | for _, f := range fields { |
| 316 | if !setting.ValidColumn(f) { |
| 317 | return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} |
| 318 | } |
| 319 | if f != setting.FieldID { |
| 320 | _spec.Node.Columns = append(_spec.Node.Columns, f) |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | if ps := suo.mutation.predicates; len(ps) > 0 { |
| 325 | _spec.Predicate = func(selector *sql.Selector) { |
| 326 | for i := range ps { |
| 327 | ps[i](selector) |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | if value, ok := suo.mutation.UpdatedAt(); ok { |
| 332 | _spec.SetField(setting.FieldUpdatedAt, field.TypeTime, value) |
| 333 | } |
| 334 | if value, ok := suo.mutation.DeletedAt(); ok { |
| 335 | _spec.SetField(setting.FieldDeletedAt, field.TypeTime, value) |
| 336 | } |
| 337 | if suo.mutation.DeletedAtCleared() { |
| 338 | _spec.ClearField(setting.FieldDeletedAt, field.TypeTime) |
| 339 | } |
| 340 | if value, ok := suo.mutation.Name(); ok { |
| 341 | _spec.SetField(setting.FieldName, field.TypeString, value) |
| 342 | } |
| 343 | if value, ok := suo.mutation.Value(); ok { |
| 344 | _spec.SetField(setting.FieldValue, field.TypeString, value) |
| 345 | } |
| 346 | if suo.mutation.ValueCleared() { |
| 347 | _spec.ClearField(setting.FieldValue, field.TypeString) |
| 348 | } |
| 349 | _node = &Setting{config: suo.config} |
| 350 | _spec.Assign = _node.assignValues |
| 351 | _spec.ScanValues = _node.scanValues |
| 352 | if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { |
| 353 | if _, ok := err.(*sqlgraph.NotFoundError); ok { |
| 354 | err = &NotFoundError{setting.Label} |
| 355 | } else if sqlgraph.IsConstraintError(err) { |
| 356 | err = &ConstraintError{msg: err.Error(), wrap: err} |
| 357 | } |
| 358 | return nil, err |
| 359 | } |
| 360 | suo.mutation.done = true |
| 361 | return _node, nil |
| 362 | } |
nothing calls this directly
no test coverage detected