From 73ad7d2ef379f46e61168853a72c36de8804f6c2 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Thu, 5 Oct 2017 21:08:40 +0300 Subject: [PATCH] Fixes 500 error on dashboard when using MSSQL (#2504) (#2662) MSSQL rejects the query: SELECT "repository"."id" FROM "repository" INNER JOIN "team_repo" ON "team_repo".repo_id="repository".id AND "repository".is_mirror=1 WHERE ( ("repository".owner_id=2 AND "repository".is_private=0) OR team_repo.team_id IN (1) ) GROUP BY "repository".id ORDER BY updated_unix DESC when the order by term (updated_unix) is not included in the group by term. --- models/org.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/org.go b/models/org.go index 63d9c0e46..461e929b9 100644 --- a/models/org.go +++ b/models/org.go @@ -671,7 +671,7 @@ func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) { Table("repository"). Join("INNER", "team_repo", "`team_repo`.repo_id=`repository`.id AND `repository`.is_mirror=?", true). Where(env.cond()). - GroupBy("`repository`.id"). + GroupBy("`repository`.id, `repository`.updated_unix"). OrderBy("updated_unix DESC"). Cols("`repository`.id"). Find(&repoIDs)