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 2018/02/07 14:52:54 UTC

[GitHub] DylanVolz closed pull request #1778: address issue with ORDER BY and GROUP BY in parameters sql statement

DylanVolz closed pull request #1778: address issue with ORDER BY and  GROUP BY in parameters sql statement
URL: https://github.com/apache/incubator-trafficcontrol/pull/1778
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_ops/traffic_ops_golang/parameters.go b/traffic_ops/traffic_ops_golang/parameters.go
index 5527b32978..37d81fd1f3 100644
--- a/traffic_ops/traffic_ops_golang/parameters.go
+++ b/traffic_ops/traffic_ops_golang/parameters.go
@@ -30,6 +30,8 @@ import (
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
 
+	"strings"
+
 	"github.com/jmoiron/sqlx"
 )
 
@@ -94,7 +96,11 @@ func getParameters(v url.Values, db *sqlx.DB, privLevel int) ([]tc.Parameter, er
 
 	query, queryValues := dbhelpers.BuildQuery(v, selectParametersQuery(), queryParamsToSQLCols)
 
-	query += ParametersGroupBy()
+	queryPieces := strings.Split(query, "ORDER BY")
+
+	queryPieces[0] += ParametersGroupBy()
+
+	query = strings.Join(queryPieces, "ORDER BY")
 	log.Debugln("Query is ", query)
 	rows, err = db.NamedQuery(query, queryValues)
 	if err != nil {
@@ -134,6 +140,6 @@ LEFT JOIN profile pr ON pp.profile = pr.id`
 }
 
 func ParametersGroupBy() string {
-	groupBy := ` GROUP BY p.config_file, p.id, p.last_updated, p.name, p.value, p.secure`
+	groupBy := ` GROUP BY p.config_file, p.id, p.last_updated, p.name, p.value, p.secure `
 	return groupBy
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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