diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb index d7130322ed1c7b28269ebd35a4a649017503a898..1736fe82ca5616d760241b2ee1c4f349783f3142 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 67c67fc53ed997f82d3dfc124a4d0d01e51b50a0..0a4216e043a1e8492dccb3a41f1c987b5be0650f 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]') diff --git a/config/feature_flags/development/include_sti_condition.yml b/config/feature_flags/development/include_sti_condition.yml deleted file mode 100644 index 88a86c74ee49ffb7552e2260bb36795846aaa1fa..0000000000000000000000000000000000000000 --- a/config/feature_flags/development/include_sti_condition.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: include_sti_condition -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72119 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343412 -milestone: '14.5' -type: development -group: group::workspace -default_enabled: false diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 6b6e68ab9371394cd3e5c512e0b46aa863660326..ce0442f27a35f4c83bc2dd0ef81efcf6e6cbd106 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -571,16 +571,6 @@ RSpec.describe Group do it 'filters out project namespace' do expect(group.descendants.find_by_id(project_namespace.id)).to be_nil end - - context 'when include_sti_condition is disabled' do - before do - stub_feature_flags(include_sti_condition: false) - end - - it 'raises an exception' do - expect { group.descendants.find_by_id(project_namespace.id)}.to raise_error(ActiveRecord::SubclassNotFound) - end - end end end end diff --git a/spec/support/shared_examples/namespaces/traversal_scope_examples.rb b/spec/support/shared_examples/namespaces/traversal_scope_examples.rb index ba28ce1b45d2e4cd824bb46cdc500b0f5370b405..f797eea6b6e23958a1f02f298e8c8e0d47cff620 100644 --- a/spec/support/shared_examples/namespaces/traversal_scope_examples.rb +++ b/spec/support/shared_examples/namespaces/traversal_scope_examples.rb @@ -25,26 +25,6 @@ RSpec.shared_examples 'namespace traversal scopes' do it { is_expected.to contain_exactly(group_1.id, group_2.id) } end - describe '.without_sti_condition' do - subject { described_class.where(type: 'Group').without_sti_condition } - - context 'when include_sti_condition is enabled' do - before do - stub_feature_flags(include_sti_condition: true) - end - - it { expect(subject.where_values_hash).to have_key('type') } - end - - context 'when include_sti_condition is disabled' do - before do - stub_feature_flags(include_sti_condition: false) - end - - it { expect(subject.where_values_hash).not_to have_key('type') } - end - end - describe '.order_by_depth' do subject { described_class.where(id: [group_1, nested_group_1, deep_nested_group_1]).order_by_depth(direction) }