dialect/sql/sqlgraph: apply predicate on update-node

This commit is contained in:
Ariel Mashraki
2021-01-22 22:45:04 +02:00
committed by Ariel Mashraki
parent 5e4d7dcbfc
commit f315801779
70 changed files with 485 additions and 13 deletions

View File

@@ -229,6 +229,13 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing User.ID for update")}
}
_spec.Node.ID.Value = id
if ps := uuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := uuo.mutation.Name(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,