srijeet0406 commented on a change in pull request #6003:
URL: https://github.com/apache/trafficcontrol/pull/6003#discussion_r683660749
##########
File path: traffic_ops/traffic_ops_golang/profile/profiles.go
##########
@@ -123,6 +124,10 @@ func (prof *TOProfile) Read(h http.Header, useIMS bool)
([]interface{}, error, e
// TODO add generic where clause to api.GenericRead
if paramValue, ok := prof.APIInfo().Params[ParamQueryParam]; ok {
+ //Check for interger value
Review comment:
Instead of checking for individual query parameters like this, we should
just add them as part of the checkers on lines 116-120.
You should also add the checker for the `ParamQueryParam` in there,
something like this:
```
queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
CDNQueryParam: dbhelpers.WhereColumnInfo{Column: "c.id", Checker:
api.IsInt},
NameQueryParam: dbhelpers.WhereColumnInfo{Column: "prof.name"},
IDQueryParam: dbhelpers.WhereColumnInfo{Column: "prof.id", Checker:
api.IsInt},
ParamQueryParam: dbhelpers.WhereColumnInfo{Column: "pp.parameter", Checker:
api.IsInt},
}
```
Then, on line 126, if `ParamQueryParam` is present, you add the `Left
Join...` subquery to the main select query.
This way, we can have one single place where we check for all the query
params.
The API v2 and v3 tests currently fail because they are passing in a param
name as an ID to the client methods. These will need to be fixed. Also, there
is this section of code in the v4 tests, which can be uncommented after the fix:
``` // TODO: figure out what the 'Parameter' field of a Profile is
and how
// passing it to this is supposed to work.
// resp, _, err = TOSession.GetProfileByParameter(pr.Parameter)
// if err != nil {
// t.Errorf("cannot GET Profile by param: %v - %v", err,
resp)
// }```
--
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]