Fix subquery issues in MySQL
This commit is contained in:
parent
6cb4b68264
commit
378c83598d
1 changed files with 14 additions and 12 deletions
|
@ -79,22 +79,24 @@ def remove_organization_member(org, user_obj):
|
||||||
raise DataModelException('Cannot remove user as they are the only organization admin')
|
raise DataModelException('Cannot remove user as they are the only organization admin')
|
||||||
|
|
||||||
with db_transaction():
|
with db_transaction():
|
||||||
# Find and remove the user from any repositorys under the org.
|
# Find and remove the user from any repositories under the org.
|
||||||
permissions = (RepositoryPermission
|
permissions = list(RepositoryPermission
|
||||||
.select(RepositoryPermission.id)
|
.select(RepositoryPermission.id)
|
||||||
.join(Repository)
|
.join(Repository)
|
||||||
.where(Repository.namespace_user == org,
|
.where(Repository.namespace_user == org,
|
||||||
RepositoryPermission.user == user_obj))
|
RepositoryPermission.user == user_obj))
|
||||||
|
|
||||||
RepositoryPermission.delete().where(RepositoryPermission.id << permissions).execute()
|
if permissions:
|
||||||
|
RepositoryPermission.delete().where(RepositoryPermission.id << permissions).execute()
|
||||||
|
|
||||||
# Find and remove the user from any teams under the org.
|
# Find and remove the user from any teams under the org.
|
||||||
members = (TeamMember
|
members = list(TeamMember
|
||||||
.select(TeamMember.id)
|
.select(TeamMember.id)
|
||||||
.join(Team)
|
.join(Team)
|
||||||
.where(Team.organization == org, TeamMember.user == user_obj))
|
.where(Team.organization == org, TeamMember.user == user_obj))
|
||||||
|
|
||||||
TeamMember.delete().where(TeamMember.id << members).execute()
|
if members:
|
||||||
|
TeamMember.delete().where(TeamMember.id << members).execute()
|
||||||
|
|
||||||
|
|
||||||
def get_organization_member_set(orgname):
|
def get_organization_member_set(orgname):
|
||||||
|
|
Reference in a new issue