Skip to content

Commit

Permalink
Use provided database Engine (#17595)
Browse files Browse the repository at this point in the history
- Don't get the engine from `db.DefaultContext`, instead use the
provided one which is passed as paramater `e`.
  • Loading branch information
Gusted committed Nov 9, 2021
1 parent 03de593 commit 3a693bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func GetUsersWhoCanCreateOrgRepo(orgID int64) ([]*User, error) {

func getUsersWhoCanCreateOrgRepo(e db.Engine, orgID int64) ([]*User, error) {
users := make([]*User, 0, 10)
return users, db.GetEngine(db.DefaultContext).
return users, e.
Join("INNER", "`team_user`", "`team_user`.uid=`user`.id").
Join("INNER", "`team`", "`team`.id=`team_user`.team_id").
Where(builder.Eq{"team.can_create_org_repo": true}.Or(builder.Eq{"team.authorize": AccessModeOwner})).
Expand Down
2 changes: 1 addition & 1 deletion models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (u *User) isVisibleToUser(e db.Engine, viewer *User) bool {
}

// Now we need to check if they in some organization together
count, err := db.GetEngine(db.DefaultContext).Table("team_user").
count, err := e.Table("team_user").
Where(
builder.And(
builder.Eq{"uid": viewer.ID},
Expand Down

0 comments on commit 3a693bd

Please sign in to comment.