From 5906268917d35d6c2cb9bef63938c6ad8770e1f2 Mon Sep 17 00:00:00 2001 From: Pablo Saavedra Date: Tue, 30 May 2017 05:24:37 +0200 Subject: [PATCH] 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. --- models/org_team.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/org_team.go b/models/org_team.go index 1b23f3a3f..76b743d9e 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)