Fix broken dependency list aggregation
What does this MR do and why?
7bd1e41b added an ignore_column
statement onto Sbom::Occurrences which causes ActiveRecord to use
select(*model.column_names)
as the default select statement instead of
SELECT *
. Since the occurrence_count
and project_count
columns are
defined inline using an AS
statement, we were dependent on SELECT *
to have these columns appear in the result set. This introduced a
regression which caused the dependency list to not correctly group
projects and locations. To fix the regression, we explicitly select
these columns in order to ensure that they appear in the result set
while ignored columns do not. The bug is further explained in this comment.
Fixes: #434134 (closed)
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Have a group with dependencies in the dependency list.
-
Start the rails console
-
Run this code:
Group.find_by_full_path('<my group>').sbom_occurrences.first.project_count
This should return a number instead of raising
NoMethodError
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.