Commit 9056548c authored by Sincheol (David) Kim's avatar Sincheol (David) Kim

Merge branch...

Merge branch '350652-corrective-action-added-column-to-members-table-causes-500-errors-to-be-returned-in-some' into 'master'

Resolve "Corrective Action: Added column to `members` table causes 500 errors to be returned in some cases"

See merge request gitlab-org/gitlab!80421
parents fcd588fe 48abe0b7
......@@ -65,10 +65,10 @@ class Member < ApplicationRecord
scope :in_hierarchy, ->(source) do
groups = source.root_ancestor.self_and_descendants
group_members = Member.default_scoped.where(source: groups)
group_members = Member.default_scoped.where(source: groups).select(*Member.cached_column_list)
projects = source.root_ancestor.all_projects
project_members = Member.default_scoped.where(source: projects)
project_members = Member.default_scoped.where(source: projects).select(*Member.cached_column_list)
Member.default_scoped.from_union([
group_members,
......
......@@ -2104,8 +2104,8 @@ class User < ApplicationRecord
def authorized_groups_without_shared_membership
Group.from_union([
groups.select(Namespace.arel_table[Arel.star]),
authorized_projects.joins(:namespace).select(Namespace.arel_table[Arel.star])
groups.select(*Namespace.cached_column_list),
authorized_projects.joins(:namespace).select(*Namespace.cached_column_list)
])
end
......
......@@ -39,6 +39,7 @@ module Projects
GroupMember
.active_without_invites_and_requests
.with_source_id(visible_groups.self_and_ancestors.pluck_primary_key)
.select(*GroupMember.cached_column_list)
end
def visible_groups
......@@ -52,11 +53,12 @@ module Projects
end
def project_members_through_ancestral_groups
project.group.present? ? project.group.members_with_parents : Member.none
members = project.group.present? ? project.group.members_with_parents : Member.none
members.select(*GroupMember.cached_column_list)
end
def individual_project_members
project.project_members
project.project_members.select(*GroupMember.cached_column_list)
end
def project_owner?
......
......@@ -376,7 +376,7 @@ Explicit column list definition:
```ruby
# Good, the SELECT columns are consistent
columns = User.cached_column_names # The helper returns fully qualified (table.column) column names (Arel)
columns = User.cached_column_list # The helper returns fully qualified (table.column) column names (Arel)
scope1 = User.select(*columns).where(id: [1, 2, 3]) # selects the columns explicitly
scope2 = User.select(*columns).where(id: [10, 11, 12]) # uses SELECT users.*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment