summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormhasbini <mohammad.hasbini@gmail.com>2017-03-30 15:38:48 +0300
committermhasbini <mohammad.hasbini@gmail.com>2017-03-30 15:38:48 +0300
commitdc15abaa221615ae57ec27cd30645879c63af1c1 (patch)
tree0beb6bc0b63df9edc89e3ae70bd378b69776bd28
parent26ba13f2038c3d5f2ceb4d9d7ffc05bfaba90ef3 (diff)
downloadgitlab-ce-dc15abaa221615ae57ec27cd30645879c63af1c1.tar.gz
Remove unnecessary ORDER BY clause from `forked_to_project_id` subquery
-rw-r--r--app/models/user.rb6
-rw-r--r--changelogs/unreleased/forked-subquery-order.yml4
2 files changed, 8 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index cbd741f96ed..95a766f2ede 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -635,8 +635,10 @@ class User < ActiveRecord::Base
end
def fork_of(project)
- links = ForkedProjectLink.where(forked_from_project_id: project, forked_to_project_id: personal_projects)
-
+ links = ForkedProjectLink.where(
+ forked_from_project_id: project,
+ forked_to_project_id: personal_projects.unscope(:order)
+ )
if links.any?
links.first.forked_to_project
else
diff --git a/changelogs/unreleased/forked-subquery-order.yml b/changelogs/unreleased/forked-subquery-order.yml
new file mode 100644
index 00000000000..06fb8236783
--- /dev/null
+++ b/changelogs/unreleased/forked-subquery-order.yml
@@ -0,0 +1,4 @@
+---
+title: Remove unnecessary ORDER BY clause from `forked_to_project_id` subquery
+merge_request:
+author: mhasbini