Skip to content

Commit e79ef77

Browse files
committed
Revert "no builder for now"
This reverts commit 4f38f65.
1 parent 4f38f65 commit e79ef77

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

models/organization/org.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,19 @@ func (org *Organization) getUserTeamIDs(ctx context.Context, userID int64) ([]in
658658
return teamIDs, db.GetEngine(ctx).
659659
Table("team").
660660
Cols("team.id").
661-
Where("`team_user`.org_id = ?", org.ID).
662-
Join("INNER", "team_user", "`team_user`.team_id = team.id").
663-
And("`team_user`.uid = ?", userID).
661+
Where(builder.In("team.id", userTeamIDbuilder(org.ID, userID))).
664662
Find(&teamIDs)
665663
}
666664

665+
func userTeamIDbuilder(orgID, userID int64) *builder.Builder {
666+
return builder.Select("team.id").From("team").
667+
InnerJoin("team_user", "team_user.team_id = team.id").
668+
Where(builder.Eq{
669+
"team_user.org_id": orgID,
670+
"team_user.uid": userID,
671+
})
672+
}
673+
667674
// TeamsWithAccessToRepo returns all teams that have given access level to the repository.
668675
func (org *Organization) TeamsWithAccessToRepo(ctx context.Context, repoID int64, mode perm.AccessMode) ([]*Team, error) {
669676
return GetTeamsWithAccessToRepo(ctx, org.ID, repoID, mode)

0 commit comments

Comments
 (0)