diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-05 15:11:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-05 15:11:48 +0000 |
commit | 81a37f05815a4c731a2d2c93302ddc554444b637 (patch) | |
tree | 447d3a8890961e63efc47280ac15f06c9c0567ff /app/models/namespaces | |
parent | f7406657b9ed27af2970a88ce4f73c35b162dfb8 (diff) | |
download | gitlab-ce-81a37f05815a4c731a2d2c93302ddc554444b637.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/namespaces')
-rw-r--r-- | app/models/namespaces/traversal/linear.rb | 3 | ||||
-rw-r--r-- | app/models/namespaces/traversal/linear_scopes.rb | 17 |
2 files changed, 3 insertions, 17 deletions
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb index d7130322ed1..1736fe82ca5 100644 --- a/app/models/namespaces/traversal/linear.rb +++ b/app/models/namespaces/traversal/linear.rb @@ -161,7 +161,7 @@ module Namespaces def lineage(top: nil, bottom: nil, hierarchy_order: nil) raise UnboundedSearch, 'Must bound search by either top or bottom' unless top || bottom - skope = self.class.without_sti_condition + skope = self.class if top skope = skope.where("traversal_ids @> ('{?}')", top.id) @@ -181,7 +181,6 @@ module Namespaces # standard SELECT to avoid mismatched attribute errors when trying to # chain future ActiveRelation commands, and retain the ordering. skope = self.class - .without_sti_condition .from(skope, self.class.table_name) .select(skope.arel_table[Arel.star]) .order(depth: hierarchy_order) diff --git a/app/models/namespaces/traversal/linear_scopes.rb b/app/models/namespaces/traversal/linear_scopes.rb index 67c67fc53ed..0a4216e043a 100644 --- a/app/models/namespaces/traversal/linear_scopes.rb +++ b/app/models/namespaces/traversal/linear_scopes.rb @@ -19,8 +19,7 @@ module Namespaces return super unless use_traversal_ids_for_ancestor_scopes? records = unscoped - .without_sti_condition - .where(id: without_sti_condition.select('unnest(traversal_ids)')) + .where(id: select('unnest(traversal_ids)')) .order_by_depth(hierarchy_order) .normal_select @@ -60,16 +59,6 @@ module Namespaces end end - # Make sure we drop the STI `type = 'Group'` condition for better performance. - # Logically equivalent so long as hierarchies remain homogeneous. - def without_sti_condition - if Feature.enabled?(:include_sti_condition, default_enabled: :yaml) - all - else - unscope(where: :type) - end - end - def order_by_depth(hierarchy_order) return all unless hierarchy_order @@ -85,7 +74,7 @@ module Namespaces # When we have queries that break this SELECT * format we can run in to errors. # For example `SELECT DISTINCT on(...)` will fail when we chain a `.count` c def normal_select - unscoped.without_sti_condition.from(all, :namespaces) + unscoped.from(all, :namespaces) end private @@ -108,7 +97,6 @@ module Namespaces namespaces = Arel::Table.new(:namespaces) records = unscoped - .without_sti_condition .with(cte.to_arel) .from([cte.table, namespaces]) @@ -136,7 +124,6 @@ module Namespaces base_ids = select(:id) records = unscoped - .without_sti_condition .from("namespaces, (#{base_ids.to_sql}) base") .where('namespaces.traversal_ids @> ARRAY[base.id]') |