Drop pre-merge access source count check

Scoped rows in the MERGE desired_sources CTE already limit
snapshots to sources visible under the scoper.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
Cursor Agent
2026-07-27 14:44:23 +00:00
parent 4d154651a8
commit 3b3d7002a9

View File

@@ -166,27 +166,6 @@ func (sources *AccessReviewCampaignSources) MergeByCampaignID(
sourceIDStrings[i] = id.String()
}
countQ := `
SELECT COUNT(DISTINCT id)
FROM access_review_sources
WHERE
%s
AND id = ANY(@access_review_source_ids::text[])
`
countQ = fmt.Sprintf(countQ, scope.SQLFragment())
countArgs := pgx.StrictNamedArgs{"access_review_source_ids": sourceIDStrings}
maps.Copy(countArgs, scope.SQLArguments())
var found int
if err := conn.QueryRow(ctx, countQ, countArgs).Scan(&found); err != nil {
return fmt.Errorf("cannot count access review sources: %w", err)
}
if found != len(uniqueSourceIDs) {
return ErrResourceNotFound
}
now := time.Now()
q := `