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