You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "ocket8888 (via GitHub)" <gi...@apache.org> on 2023/03/14 14:35:06 UTC
[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #7402: add missing lastUpdated prop to PUT /roles
ocket8888 commented on code in PR #7402:
URL: https://github.com/apache/trafficcontrol/pull/7402#discussion_r1135651558
##########
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:
comparisons with errors should use [`errors.Is`](https://pkg.go.dev/errors#Is) rather than `==`.
--
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: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org