(ctx context.Context)
| 276 | } |
| 277 | |
| 278 | func (_u *MediaUpdateOne) sqlSave(ctx context.Context) (_node *Media, err error) { |
| 279 | _spec := sqlgraph.NewUpdateSpec(media.Table, media.Columns, sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt)) |
| 280 | id, ok := _u.mutation.ID() |
| 281 | if !ok { |
| 282 | return nil, &ValidationError{Name: "id", err: errors.New(`entv2: missing "Media.id" for update`)} |
| 283 | } |
| 284 | _spec.Node.ID.Value = id |
| 285 | if fields := _u.fields; len(fields) > 0 { |
| 286 | _spec.Node.Columns = make([]string, 0, len(fields)) |
| 287 | _spec.Node.Columns = append(_spec.Node.Columns, media.FieldID) |
| 288 | for _, f := range fields { |
| 289 | if !media.ValidColumn(f) { |
| 290 | return nil, &ValidationError{Name: f, err: fmt.Errorf("entv2: invalid field %q for query", f)} |
| 291 | } |
| 292 | if f != media.FieldID { |
| 293 | _spec.Node.Columns = append(_spec.Node.Columns, f) |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | if ps := _u.mutation.predicates; len(ps) > 0 { |
| 298 | _spec.Predicate = func(selector *sql.Selector) { |
| 299 | for i := range ps { |
| 300 | ps[i](selector) |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | if value, ok := _u.mutation.Source(); ok { |
| 305 | _spec.SetField(media.FieldSource, field.TypeString, value) |
| 306 | } |
| 307 | if _u.mutation.SourceCleared() { |
| 308 | _spec.ClearField(media.FieldSource, field.TypeString) |
| 309 | } |
| 310 | if value, ok := _u.mutation.SourceURI(); ok { |
| 311 | _spec.SetField(media.FieldSourceURI, field.TypeString, value) |
| 312 | } |
| 313 | if _u.mutation.SourceURICleared() { |
| 314 | _spec.ClearField(media.FieldSourceURI, field.TypeString) |
| 315 | } |
| 316 | if value, ok := _u.mutation.Text(); ok { |
| 317 | _spec.SetField(media.FieldText, field.TypeString, value) |
| 318 | } |
| 319 | if _u.mutation.TextCleared() { |
| 320 | _spec.ClearField(media.FieldText, field.TypeString) |
| 321 | } |
| 322 | _node = &Media{config: _u.config} |
| 323 | _spec.Assign = _node.assignValues |
| 324 | _spec.ScanValues = _node.scanValues |
| 325 | if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { |
| 326 | if _, ok := err.(*sqlgraph.NotFoundError); ok { |
| 327 | err = &NotFoundError{media.Label} |
| 328 | } else if sqlgraph.IsConstraintError(err) { |
| 329 | err = &ConstraintError{msg: err.Error(), wrap: err} |
| 330 | } |
| 331 | return nil, err |
| 332 | } |
| 333 | _u.mutation.done = true |
| 334 | return _node, nil |
| 335 | } |
nothing calls this directly
no test coverage detected