srijeet0406 commented on a change in pull request #6003:
URL: https://github.com/apache/trafficcontrol/pull/6003#discussion_r685726633



##########
File path: traffic_ops/traffic_ops_golang/profile/profiles.go
##########
@@ -113,19 +113,19 @@ func (prof *TOProfile) Read(h http.Header, useIMS bool) 
([]interface{}, error, e
        // Query Parameters to Database Query column mappings
        // see the fields mapped in the SQL query
        queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
-               CDNQueryParam:  dbhelpers.WhereColumnInfo{Column: "c.id"},
-               NameQueryParam: dbhelpers.WhereColumnInfo{Column: "prof.name"},
-               IDQueryParam:   dbhelpers.WhereColumnInfo{Column: "prof.id", 
Checker: api.IsInt},
+               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},
        }
        where, orderBy, pagination, queryValues, errs := 
dbhelpers.BuildWhereAndOrderByAndPagination(prof.APIInfo().Params, 
queryParamsToQueryCols)
 
        // Narrow down if the query parameter is 'param'
-
        // TODO add generic where clause to api.GenericRead
        if paramValue, ok := prof.APIInfo().Params[ParamQueryParam]; ok {
                queryValues["parameter_id"] = paramValue
                if len(paramValue) > 0 {
-                       where += " LEFT JOIN profile_parameter pp ON prof.id  = 
pp.profile where pp.parameter=:parameter_id"
+                       where = " LEFT JOIN profile_parameter pp ON prof.id = 
pp.profile " + where + " AND pp.parameter=:parameter_id"

Review comment:
       No, the `WHERE` clause will be created by the 
`BuildWhereAndOrderByAndPagination` function and you dont need to account for 
it, if you're passing in all the right query params into it.




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


Reply via email to