rawlinp commented on a change in pull request #5922:
URL: https://github.com/apache/trafficcontrol/pull/5922#discussion_r647789667



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -1070,87 +1189,88 @@ func updateV40(w http.ResponseWriter, r *http.Request, 
inf *api.APIInfo, dsV40 *
 
        if err != nil {
                usrErr, sysErr, code := api.ParseDBError(err)
-               return nil, code, usrErr, sysErr
+               return nil, alerts, code, usrErr, sysErr
        }
        defer resultRows.Close()
        if !resultRows.Next() {
-               return nil, http.StatusNotFound, errors.New("no delivery 
service found with this id"), nil
+               return nil, alerts, http.StatusNotFound, errors.New("no 
delivery service found with this id"), nil
        }
-       lastUpdated := tc.TimeNoMod{}
+       var lastUpdated time.Time
        if err := resultRows.Scan(&lastUpdated); err != nil {
-               return nil, http.StatusInternalServerError, nil, 
errors.New("scan updating delivery service: " + err.Error())
+               return nil, alerts, http.StatusInternalServerError, nil, 
errors.New("scan updating delivery service: " + err.Error())
        }
        if resultRows.Next() {
-               xmlID := ""
-               if ds.XMLID != nil {
-                       xmlID = *ds.XMLID
-               }
-               return nil, http.StatusInternalServerError, nil, 
errors.New("updating delivery service " + xmlID + ": " + "this update affected 
too many rows: > 1")
+               return nil, alerts, http.StatusInternalServerError, nil, 
errors.New("updating delivery service " + ds.XMLID + ": " + "this update 
affected too many rows: > 1")
        }
 
        if ds.ID == nil {
-               return nil, http.StatusInternalServerError, nil, 
errors.New("missing id after update")
+               return nil, alerts, http.StatusInternalServerError, nil, 
errors.New("missing id after update")
        }
-       if ds.XMLID == nil {
-               return nil, http.StatusInternalServerError, nil, 
errors.New("missing xml_id after update")
-       }
-       if ds.TypeID == nil {
-               return nil, http.StatusInternalServerError, nil, 
errors.New("missing type after update")
-       }
-       if ds.RoutingName == nil {
-               return nil, http.StatusInternalServerError, nil, 
errors.New("missing routing name after update")
+
+       if inf.Version != nil && inf.Version.Major >= 4 {

Review comment:
       That's ok, if the extra DB calls for prior API versions is a big deal to 
clients, they are free to use the latest API version 😄 . However, I think the 
overhead of 1 extra DB query is super negligible.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to