Merge branch 'rails5-exists-query' into 'master'

Replace `.exists` with `EXISTS ()`

Closes #46277

See merge request gitlab-org/gitlab-ce!19178
This commit is contained in:
Yorick Peterse 2018-05-31 11:22:34 +00:00
commit 7f32b9d7b5
1 changed files with 3 additions and 5 deletions

View File

@ -63,7 +63,7 @@ module Boards
def without_board_labels(issues) def without_board_labels(issues)
return issues unless board_label_ids.any? return issues unless board_label_ids.any?
issues.where.not(issues_label_links.limit(1).arel.exists) issues.where.not('EXISTS (?)', issues_label_links.limit(1))
end end
def issues_label_links def issues_label_links
@ -71,10 +71,8 @@ module Boards
end end
def with_list_label(issues) def with_list_label(issues)
issues.where( issues.where('EXISTS (?)', LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id") .where("label_links.label_id = ?", list.label_id).limit(1))
.where("label_links.label_id = ?", list.label_id).limit(1).arel.exists
)
end end
end end
end end