MCPcopy
hub / github.com/Wei-Shaw/sub2api / sqlSave

Method sqlSave

backend/ent/paymentauditlog_update.go:303–357  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

301}
302
303func (_u *PaymentAuditLogUpdateOne) sqlSave(ctx context.Context) (_node *PaymentAuditLog, err error) {
304 if err := _u.check(); err != nil {
305 return _node, err
306 }
307 _spec := sqlgraph.NewUpdateSpec(paymentauditlog.Table, paymentauditlog.Columns, sqlgraph.NewFieldSpec(paymentauditlog.FieldID, field.TypeInt64))
308 id, ok := _u.mutation.ID()
309 if !ok {
310 return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PaymentAuditLog.id" for update`)}
311 }
312 _spec.Node.ID.Value = id
313 if fields := _u.fields; len(fields) > 0 {
314 _spec.Node.Columns = make([]string, 0, len(fields))
315 _spec.Node.Columns = append(_spec.Node.Columns, paymentauditlog.FieldID)
316 for _, f := range fields {
317 if !paymentauditlog.ValidColumn(f) {
318 return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
319 }
320 if f != paymentauditlog.FieldID {
321 _spec.Node.Columns = append(_spec.Node.Columns, f)
322 }
323 }
324 }
325 if ps := _u.mutation.predicates; len(ps) > 0 {
326 _spec.Predicate = func(selector *sql.Selector) {
327 for i := range ps {
328 ps[i](selector)
329 }
330 }
331 }
332 if value, ok := _u.mutation.OrderID(); ok {
333 _spec.SetField(paymentauditlog.FieldOrderID, field.TypeString, value)
334 }
335 if value, ok := _u.mutation.Action(); ok {
336 _spec.SetField(paymentauditlog.FieldAction, field.TypeString, value)
337 }
338 if value, ok := _u.mutation.Detail(); ok {
339 _spec.SetField(paymentauditlog.FieldDetail, field.TypeString, value)
340 }
341 if value, ok := _u.mutation.Operator(); ok {
342 _spec.SetField(paymentauditlog.FieldOperator, field.TypeString, value)
343 }
344 _node = &PaymentAuditLog{config: _u.config}
345 _spec.Assign = _node.assignValues
346 _spec.ScanValues = _node.scanValues
347 if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
348 if _, ok := err.(*sqlgraph.NotFoundError); ok {
349 err = &NotFoundError{paymentauditlog.Label}
350 } else if sqlgraph.IsConstraintError(err) {
351 err = &ConstraintError{msg: err.Error(), wrap: err}
352 }
353 return nil, err
354 }
355 _u.mutation.done = true
356 return _node, nil
357}

Callers

nothing calls this directly

Calls 8

checkMethod · 0.95
OrderIDMethod · 0.80
ActionMethod · 0.80
DetailMethod · 0.80
OperatorMethod · 0.80
ErrorMethod · 0.65
IDMethod · 0.45
SetFieldMethod · 0.45

Tested by

no test coverage detected