diff options
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/routable.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index bdd87437e2a..129d0fbb2c0 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -51,14 +51,21 @@ module Routable # Klass.where_full_path_in(%w{gitlab-org/gitlab-foss gitlab-org/gitlab}) # # Returns an ActiveRecord::Relation. - def where_full_path_in(paths) + def where_full_path_in(paths, use_includes: true) return none if paths.empty? wheres = paths.map do |path| "(LOWER(routes.path) = LOWER(#{connection.quote(path)}))" end - includes(:route).where(wheres.join(' OR ')).references(:routes) + route = + if use_includes + includes(:route).references(:routes) + else + joins(:route) + end + + route.where(wheres.join(' OR ')) end end |