tinfoil-knight commented on code in PR #7402:
URL: https://github.com/apache/trafficcontrol/pull/7402#discussion_r1135691441
##########
traffic_ops/traffic_ops_golang/role/roles.go:
##########
@@ -394,24 +395,15 @@ func Update(w http.ResponseWriter, r *http.Request) {
api.HandleErr(w, r, tx, http.StatusPreconditionFailed,
api.ResourceModifiedError, nil)
return
}
- rows, err := tx.Query(updateRoleQuery(), roleV4.Name,
roleV4.Description, currentRoleName)
+ err = tx.QueryRow(updateRoleQuery(), roleV4.Name, roleV4.Description,
currentRoleName).Scan(&roleV4.LastUpdated)
if err != nil {
- usrErr, sysErr, code := api.ParseDBError(err)
- api.HandleErr(w, r, tx, code, usrErr, fmt.Errorf("updating
role: %w", sysErr))
- return
- }
- defer rows.Close()
- if !rows.Next() {
- api.HandleErr(w, r, tx, http.StatusNotFound, errors.New("no
such role"), nil)
- return
- }
- var lastUpdated time.Time
- for rows.Next() {
- if err := rows.Scan(&lastUpdated); err != nil {
- api.HandleErr(w, r, tx, http.StatusInternalServerError,
nil, fmt.Errorf("scanning lastUpdated from role update: %w", err))
+ if err == sql.ErrNoRows {
Review Comment:
Updated to include the preferred method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]