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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user