You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "jagan-parthiban (via GitHub)" <gi...@apache.org> on 2023/03/10 18:36:04 UTC

[GitHub] [trafficcontrol] jagan-parthiban commented on a diff in pull request #7383: Fixes service_categories response to POST API

jagan-parthiban commented on code in PR #7383:
URL: https://github.com/apache/trafficcontrol/pull/7383#discussion_r1132739214


##########
traffic_ops/traffic_ops_golang/api/generic_crud.go:
##########
@@ -119,19 +119,39 @@ func GenericCreateNameBasedID(val GenericCreator) (error, error, int) {
 	}
 	defer resultRows.Close()
 
+	var name string
 	lastUpdated := tc.TimeNoMod{}
 	rowsAffected := 0
-	for resultRows.Next() {
-		rowsAffected++
-		if err := resultRows.Scan(&lastUpdated); err != nil {
-			return nil, errors.New(val.GetType() + " create scanning: " + err.Error()), http.StatusInternalServerError
+
+	// Only when the type is of serviceCategory, &name is scanned and returned from the DB.
+	// Else return only &lastUpdated.
+	if val.GetType() == "serviceCategory" {
+		for resultRows.Next() {

Review Comment:
   Suggestion Implemented



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