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:
authorSean McGivern <sean@gitlab.com>2019-02-20 14:31:06 +0300
committerSean McGivern <sean@gitlab.com>2019-02-20 14:31:06 +0300
commit843f4b94b59255ec27b3bdf22e93180fce74ddca (patch)
treef7ec7659c40eb0ff6ea67a1346a47f7d7d7a4e65 /app/finders
parentd83e5740e83bbee963279c9af85fb585517cb643 (diff)
Ignore ordering when calling find_by on finders
We shouldn't care about the ordering here; if we did, it would be more appropriate to use `take` or `first`. Having the ordering can result in the database picking a bad query plan, as it might think sorting the whole table first is the best option.
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/concerns/finder_methods.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/finders/concerns/finder_methods.rb b/app/finders/concerns/finder_methods.rb
index 5290313585f..8de3276184d 100644
--- a/app/finders/concerns/finder_methods.rb
+++ b/app/finders/concerns/finder_methods.rb
@@ -3,13 +3,13 @@
module FinderMethods
# rubocop: disable CodeReuse/ActiveRecord
def find_by!(*args)
- raise_not_found_unless_authorized execute.find_by!(*args)
+ raise_not_found_unless_authorized execute.reorder(nil).find_by!(*args)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def find_by(*args)
- if_authorized execute.find_by(*args)
+ if_authorized execute.reorder(nil).find_by(*args)
end
# rubocop: enable CodeReuse/ActiveRecord