Skip to content
Snippets Groups Projects
Commit 072b83c9 authored by Thong Kuah's avatar Thong Kuah
Browse files

Remove authorize_groups_query_without_column_cache feature flag

This enables the query for User#authorized_groups to have consistent
columns by default

Changelog: other
parent 475fa4e8
No related branches found
No related tags found
1 merge request!122130Remove authorize_groups_query_without_column_cache feature flag
......@@ -2401,19 +2401,11 @@ def group_callouts_by_feature_name
end
def authorized_groups_without_shared_membership
if Feature.enabled?(:authorize_groups_query_without_column_cache)
Group.from_union(
[
groups.select(Namespace.default_select_columns),
authorized_projects.joins(:namespace).select(Namespace.default_select_columns)
])
else
Group.from_union(
[
groups.select(*Namespace.cached_column_list),
authorized_projects.joins(:namespace).select(*Namespace.cached_column_list)
])
end
Group.from_union(
[
groups.select(Namespace.default_select_columns),
authorized_projects.joins(:namespace).select(Namespace.default_select_columns)
])
end
def authorized_groups_with_shared_membership
......
---
name: authorize_groups_query_without_column_cache
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/121613
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/412833
milestone: '16.1'
type: development
group: group::tenant scale
default_enabled: false
......@@ -4418,7 +4418,7 @@ def login_method(login)
end
end
shared_examples '#authorized_groups shared' do
describe '#authorized_groups' do
let!(:user) { create(:user) }
let!(:private_group) { create(:group) }
let!(:child_group) { create(:group, parent: private_group) }
......@@ -4447,31 +4447,17 @@ def login_method(login)
it { is_expected.to include shared_group }
it { is_expected.not_to include other_group }
end
end
describe '#authorized_groups' do
context 'authorize_groups_query_without_column_cache FF enabled' do
it_behaves_like '#authorized_groups shared' do
context 'when a new column is added to namespaces table' do
before do
ApplicationRecord.connection.execute "ALTER TABLE namespaces ADD COLUMN _test_column_xyz INT NULL"
end
# We sanity check that we don't get:
# ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: each UNION query must have the same number of columns
it 'will not raise errors' do
expect { subject.count }.not_to raise_error
end
end
end
end
context 'authorize_groups_query_without_column_cache FF disabled' do
context 'when a new column is added to namespaces table' do
before do
stub_feature_flags(authorize_groups_query_without_column_cache: false)
ApplicationRecord.connection.execute "ALTER TABLE namespaces ADD COLUMN _test_column_xyz INT NULL"
end
it_behaves_like '#authorized_groups shared'
# We sanity check that we don't get:
# ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: each UNION query must have the same number of columns
it 'will not raise errors' do
expect { subject.count }.not_to raise_error
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment