aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-04 16:00:00 -0500
committerUnknwon <u@gogs.io>2016-03-04 16:00:00 -0500
commit5335e671be6671383814770dd69a285d0016d26f (patch)
tree6a11c972e51a83a9ee99e1a95ee38e740881ca46
parent2d2d85bba4dd5131e72db533c31aab423f86232e (diff)
downloadgitea-5335e671be6671383814770dd69a285d0016d26f.tar.gz
gitea-5335e671be6671383814770dd69a285d0016d26f.zip
#2743 more fixes on SQL errors
-rw-r--r--models/org.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/org.go b/models/org.go
index c52060c378..1fee4f522d 100644
--- a/models/org.go
+++ b/models/org.go
@@ -1089,12 +1089,12 @@ GROUP BY repository.id`,
// GetTeams returns all teams that belong to organization,
// and that the user has joined.
func (org *User) GetUserTeams(userID int64) error {
- if err := x.Cols("`team`.*").
- Where("`team_user`.org_id=?", org.Id).
- And("`team_user`.uid=?", userID).
- Join("INNER", "`team_user`", "`team_user`.team_id=`team`.id").
- Find(&org.Teams); err != nil {
- return fmt.Errorf("GetUserTeams: %v", err)
+ teams := make([]*Team, 0, 5)
+ if err := x.Sql(`SELECT team.* FROM team
+INNER JOIN team_user ON team_user.team_id = team.id
+WHERE team_user.org_id = ? AND team_user.uid = ?`,
+ org.Id, userID).Find(&teams); err != nil {
+ return fmt.Errorf("get teams: %v", err)
}
// FIXME: should I change this value inside method,