You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2019/06/20 17:22:10 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #3580: TO: Added ReadBack function to fix "joined fields" issue

ocket8888 commented on a change in pull request #3580: TO: Added ReadBack function to fix "joined fields" issue
URL: https://github.com/apache/trafficcontrol/pull/3580#discussion_r295905806
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/api/generic_crud.go
 ##########
 @@ -80,8 +81,33 @@ func GenericCreate(val GenericCreator) (error, error, int) {
 	} else if rowsAffected > 1 {
 		return nil, errors.New("too many ids returned from " + val.GetType() + " insert"), http.StatusInternalServerError
 	}
+
 	val.SetKeys(map[string]interface{}{"id": id})
 	val.SetLastUpdated(lastUpdated)
+
+	if r, ok := val.(Reader); ok {
+		return ReadBack(r)
+	}
+
+	return nil, nil, http.StatusOK
+}
+
+func ReadBack(val Reader) (error, error, int) {
+
+	i := val.(Identifier)
+	keys, _ := i.GetKeys()
+	inf := val.APIInfo()
+	inf.Params["id"] = strconv.Itoa(keys["id"].(int))
 
 Review comment:
   This'll panic if the object doesn't have an `id`, which sort of defeats the purpose of `APIInfo.IntParams` and `Reader.GetKeys`.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services