Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-05-17 06:17:02 +0300
committerStan Hu <stanhu@gmail.com>2017-05-17 06:20:41 +0300
commit6ea4d333c275a639c6ea7f8f6a85b5f34f03dbba (patch)
tree1b96f433a59cfba20143f3694d7a1268236e7ee3
parent39baadbd017a1e36cf95b0ad1a503015bd5e562f (diff)
Fix deletion of issue assignees for MySQL
MySQL builds on EE were failing due to MySQL not liking the complex subqueries. Simplify the deletion to use a subquery that works.
-rw-r--r--app/services/members/authorized_destroy_service.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/services/members/authorized_destroy_service.rb b/app/services/members/authorized_destroy_service.rb
index eac7ef0c9b7..9e84e2a8f62 100644
--- a/app/services/members/authorized_destroy_service.rb
+++ b/app/services/members/authorized_destroy_service.rb
@@ -37,10 +37,15 @@ module Members
else
project = member.source
- IssueAssignee.delete_all(
- user_id: member.user_id,
- issue_id: project.issues.opened.assigned_to(member.user).select(:id)
- )
+ # SELECT 1 FROM issues WHERE issues.id = issue_assignees.issue_id AND issues.project_id = X
+ issues = Issue.unscoped.select(1).
+ where('issues.id = issue_assignees.issue_id').
+ where(project_id: project.id)
+
+ # DELETE FROM issue_assignees WHERE user_id = X AND EXISTS (...)
+ IssueAssignee.unscoped.
+ where('user_id = :user_id AND EXISTS (:sub)', user_id: member.user_id, sub: issues).
+ delete_all
project.merge_requests.opened.assigned_to(member.user).update_all(assignee_id: nil)
end