Add tenant scoping to LoadAllByCookieBannerID

Every other LoadAll* method in coredata takes a Scoper parameter
for tenant isolation. LoadAllByCookieBannerID was the only one
that omitted it, making the isolation invariant depend entirely
on callers first loading the banner with a scoped query.

Add scope.SQLFragment to the WHERE clause to match the pattern
used by the paginated sibling LoadByCookieBannerID.

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-04-13 19:14:33 +02:00
parent 3d36d93e32
commit a3bb5423a8
2 changed files with 11 additions and 6 deletions

View File

@@ -212,6 +212,7 @@ WHERE
func (c *CookieCategories) LoadAllByCookieBannerID(
ctx context.Context,
conn pg.Querier,
scope Scoper,
cookieBannerID gid.GID,
) error {
q := `
@@ -229,12 +230,16 @@ SELECT
FROM
cookie_categories
WHERE
cookie_banner_id = @cookie_banner_id
%s
AND cookie_banner_id = @cookie_banner_id
ORDER BY
rank ASC, id ASC;
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"cookie_banner_id": cookieBannerID}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {