diff options
author | Pablo Saavedra <saavedra.pablo@gmail.com> | 2017-05-30 05:24:37 +0200 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2017-05-29 23:24:37 -0400 |
commit | 5906268917d35d6c2cb9bef63938c6ad8770e1f2 (patch) | |
tree | 835949433029982b60b0cfe6325420eb3198981f /models/org_team.go | |
parent | a1d411a0182dd5c5ba227acf43781181c11a1ae3 (diff) |
models/org_team: getUserTeams uses includes always -1 in the IN statement (#4412)
Ensure that the IN clause contains one value at least. The idea is avoid a
syntax error in the SQL sentence and rollbacks in the transactions.
For example:
ERROR: syntax error at or near ")"
LINE 1: ...RE ... and team.id IN ();
We will always add the -1 value in the IN list.
Diffstat (limited to 'models/org_team.go')
-rw-r--r-- | models/org_team.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/models/org_team.go b/models/org_team.go index 1b23f3a3..76b743d9 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -450,10 +450,11 @@ func getUserTeams(e Engine, orgID, userID int64) ([]*Team, error) { return nil, err } - teamIDs := make([]int64, len(teamUsers)) + teamIDs := make([]int64, len(teamUsers)+1) for i := range teamUsers { teamIDs[i] = teamUsers[i].TeamID } + teamIDs[len(teamUsers)] = -1 teams := make([]*Team, 0, len(teamIDs)) return teams, e.Where("org_id = ?", orgID).In("id", teamIDs).Find(&teams) |