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 2020/04/20 21:04:52 UTC

[GitHub] [trafficcontrol] mitchell852 commented on a change in pull request #4634: Fixing the query to get mid servers

mitchell852 commented on a change in pull request #4634:
URL: https://github.com/apache/trafficcontrol/pull/4634#discussion_r411691233



##########
File path: traffic_ops/traffic_ops_golang/server/servers.go
##########
@@ -335,14 +335,12 @@ func getMidServers(servers []tc.ServerNullable, tx *sqlx.Tx) ([]tc.ServerNullabl
 	edgeIDs := strings.Join(ids, ",")
 	// TODO: include secondary parent?
 	q := selectQuery() + `
-WHERE s.id IN (
-	SELECT mid.id FROM server mid
-	JOIN cachegroup cg ON cg.id IN (
-		SELECT cg.parent_cachegroup_id
-		FROM server s
-		JOIN cachegroup cg ON cg.id = s.cachegroup
-		WHERE s.id IN (` + edgeIDs + `))
-	JOIN type t ON mid.type = (SELECT id FROM type WHERE name = 'MID'))
+JOIN type AS t ON s.type = t.id

Review comment:
       I'm getting the following error when trying to hit the endpoint that calls this query:
   
   ```
   GET /api/2.0/servers?dsId=22 HTTP/1.1" 400
   pq: table name "t" specified more than once
   ```




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