1
0
Fork 0
forked from forgejo/forgejo

#2743 workaround to fix XORM problem

This commit is contained in:
Unknwon 2016-03-03 10:57:27 -05:00
parent 4d930f3598
commit c9901bbba5
5 changed files with 9 additions and 7 deletions

View file

@ -1055,8 +1055,7 @@ func RemoveOrgRepo(orgID, repoID int64) error {
// that the user with the given userID has access to.
func (org *User) GetUserRepositories(userID int64) (err error) {
teams := make([]*Team, 0, 10)
if err = x.Cols("`team`.id").
Where("`team_user`.org_id=?", org.Id).
if err = x.Where("`team_user`.org_id=?", org.Id).
And("`team_user`.uid=?", userID).
Join("INNER", "`team_user`", "`team_user`.team_id=`team`.id").
Find(&teams); err != nil {
@ -1076,8 +1075,7 @@ func (org *User) GetUserRepositories(userID int64) (err error) {
// As a workaround, we have to build the IN statement on our own, until this is fixed.
// https://github.com/go-xorm/xorm/issues/342
if err = x.Cols("`repository`.*").
Join("INNER", "`team_repo`", "`team_repo`.repo_id=`repository`.id").
if err = x.Join("INNER", "`team_repo`", "`team_repo`.repo_id=`repository`.id").
Where("`repository`.owner_id=?", org.Id).
And("`repository`.is_private=?", false).
Or("`team_repo`.team_id IN (?)", strings.Join(teamIDs, ",")).