Conversation
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
1 similar comment
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
|
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
This PR changes the organizations advanced query SQL to always use a LEFT JOIN to organizationSegmentsAgg, regardless of whether aggregate fields are requested, so organizations without matching aggregate rows are still returned.
Changes:
- Replace the conditional
INNER JOIN/LEFT JOINselection fororganizationSegmentsAggwith a consistentLEFT JOIN. - Preserve the segment join predicate while altering join semantics (no longer filtering organizations out via the join).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| : ` LEFT JOIN "organizationSegmentsAgg" osa ON osa."organizationId" = o.id AND ${ | ||
| segmentId ? `osa."segmentId" = $(segmentId)` : `osa."segmentId" IS NULL` | ||
| }` | ||
| LEFT JOIN "organizationSegmentsAgg" osa ON osa."organizationId" = o.id AND ${ |
| LEFT JOIN "organizationSegmentsAgg" osa ON osa."organizationId" = o.id AND ${ | ||
| segmentId ? `osa."segmentId" = $(segmentId)` : `osa."segmentId" IS NULL` | ||
| } |
Note
Medium Risk
Changes the
organizationsadvanced query to no longer require a matchingorganizationSegmentsAggrow when aggregates are requested, which can alter result sets/counts and ordering for segment-scoped queries. Risk is moderate due to query semantics/performance changes but limited to read-path SQL joins.Overview
Updates the organizations advanced search SQL to always
LEFT JOINorganizationSegmentsAgg(instead of conditionally using anINNER JOINwhen aggregates are included).This ensures organizations without matching aggregate rows for the requested segment (or null segment) can still be returned, with aggregate fields continuing to rely on
coalesce(...)defaults.Reviewed by Cursor Bugbot for commit e4ff931. Bugbot is set up for automated code reviews on this repo. Configure here.