This reverts commit 6c0b3a8a1c.
This commit is contained in:
3 files changed
+2
-164
No files matched your search
@@ -76,40 +76,3 @@ func (r *Repository) UpsertController(ctx context.Context, controller *Controlle
|
||||
|
||||
return int(rowsUpdated), nil
|
||||
}
|
||||
|
||||
func (r *Repository) UpdateController(ctx context.Context, controller *Controller) (int, error) {
|
||||
const op = "server.(Repository).UpdateController"
|
||||
|
||||
if controller == nil {
|
||||
return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "controller is nil")
|
||||
}
|
||||
if controller.PrivateId == "" {
|
||||
return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "controller private_id is empty")
|
||||
}
|
||||
if controller.Address == "" {
|
||||
return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "controller address is empty")
|
||||
}
|
||||
|
||||
var rowsUpdated int
|
||||
_, err := r.writer.DoTx(
|
||||
ctx,
|
||||
db.StdRetryCnt,
|
||||
db.ExpBackoff{},
|
||||
func(reader db.Reader, w db.Writer) error {
|
||||
var err error
|
||||
rowsUpdated, err = w.Update(ctx, controller, []string{"description", "address"}, nil, db.WithWhere("private_id = ?", controller.PrivateId))
|
||||
if err != nil {
|
||||
return errors.Wrap(ctx, err, op+":Update")
|
||||
}
|
||||
if rowsUpdated > 1 {
|
||||
return errors.New(ctx, errors.MultipleRecords, op, "more than 1 resource would have been updated")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return db.NoRowsAffected, err
|
||||
}
|
||||
|
||||
return rowsUpdated, nil
|
||||
}
|
||||
Reference in new issue
Block a user