mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
@@ -571,33 +571,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (u *User, err error) {
|
||||
spec.Edges.Add = append(spec.Edges.Add, edge)
|
||||
}
|
||||
u = &User{config: uuo.config}
|
||||
spec.ScanTypes = []interface{}{
|
||||
&sql.NullInt64{},
|
||||
&sql.NullInt64{},
|
||||
&sql.NullString{},
|
||||
}
|
||||
spec.Assign = func(values ...interface{}) error {
|
||||
if m, n := len(values), len(spec.ScanTypes); m != n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
value, ok := values[0].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
u.ID = int(value.Int64)
|
||||
values = values[1:]
|
||||
if value, ok := values[0].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field age", values[0])
|
||||
} else if value.Valid {
|
||||
u.Age = int(value.Int64)
|
||||
}
|
||||
if value, ok := values[1].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[1])
|
||||
} else if value.Valid {
|
||||
u.Name = value.String
|
||||
}
|
||||
return nil
|
||||
}
|
||||
spec.Assign = u.assignValues
|
||||
spec.ScanValues = u.scanValues()
|
||||
if err = sqlgraph.UpdateNode(ctx, uuo.driver, spec); err != nil {
|
||||
if cerr, ok := isSQLConstraintError(err); ok {
|
||||
err = cerr
|
||||
|
||||
Reference in New Issue
Block a user