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



##########
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:
       If I didn't change the where as per above statement, the query looks 
incorrect. 
   SELECT prof.description, prof.id, prof.last_updated, prof.name, 
prof.routing_disabled, prof.type, c.id as cdn, c.name as cdn_name FROM profile 
prof
   LEFT JOIN cdn c ON prof.cdn = c.id
   WHERE pp.parameter=:param 
   LEFT JOIN profile_parameter pp ON prof.id  = pp.profile.




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