Comment 4 for bug 745310

Revision history for this message
Robert Collins (lifeless) wrote :

however, for this case - where the source branch is constrained, we actually want this form of query:
SELECT COUNT(*)
FROM BranchMergeProposal join branch as source on source.id=branchmergeproposal.source_branch and source.owner=2287822 join branch as target on target.id=branchmergeproposal.target_branch
WHERE source.private = false or source.id in(
                               (SELECT Branch.id
                                FROM Branch,
                                     TeamParticipation
                                WHERE Branch.OWNER = TeamParticipation.team
                                  AND TeamParticipation.person = 2287822
                                  AND Branch.private = TRUE)
                             UNION
                               (SELECT Branch.id
                                FROM Branch,
                                     BranchSubscription,
                                     TeamParticipation
                                WHERE BranchSubscription.branch = Branch.id
                                  AND BranchSubscription.person = TeamParticipation.team
                                  AND TeamParticipation.person = 2287822
                                  AND Branch.private = TRUE))
  AND target.private=false or target.id IN(
                          (SELECT Branch.id
                           FROM Branch,
                                TeamParticipation
                           WHERE Branch.OWNER = TeamParticipation.team
                             AND TeamParticipation.person = 2287822
                             AND Branch.private = TRUE)
                        UNION
                          (SELECT Branch.id
                           FROM Branch,
                                BranchSubscription,
                                TeamParticipation
                           WHERE BranchSubscription.branch = Branch.id
                             AND BranchSubscription.person = TeamParticipation.team
                             AND TeamParticipation.person = 2287822
                             AND Branch.private = TRUE))
  AND BranchMergeProposal.queue_status IN (3,
                                           2)