feat: uses left join in query organizations#4016
Conversation
|
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.
Signed-off-by: Umberto Sgueglia <[email protected]>
e4ff931 to
2199c18
Compare
|
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2199c18. Configure here.

Note
Medium Risk
Changes SQL join semantics for
OrganizationRepository.findAndCountAll, which can alter which organizations appear (and counts) when aggregates are requested, especially for orgs lacking aggregate rows.Overview
Updates the organizations advanced query in
organizationRepository.tsto alwaysLEFT JOINorganizationSegmentsAgg(previouslyINNER JOINwheninclude.aggregateswas enabled).This means organization list/count queries with aggregates will now include organizations even when no matching aggregate row exists for the requested segment (leaving aggregate fields
NULL/coalesced), instead of filtering them out.Reviewed by Cursor Bugbot for commit 2199c18. Bugbot is set up for automated code reviews on this repo. Configure here.