From b77541998fe13a994d39134a9824ae3f71b5afa7 Mon Sep 17 00:00:00 2001 From: adlerhurst <27845747+adlerhurst@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:21:22 +0100 Subject: [PATCH] only update wrong grants --- internal/eventstore/handler/v2/statement.go | 6 ++++++ internal/query/projection/project_grant.go | 1 + 2 files changed, 7 insertions(+) diff --git a/internal/eventstore/handler/v2/statement.go b/internal/eventstore/handler/v2/statement.go index 961881d24b..a02e5d3580 100644 --- a/internal/eventstore/handler/v2/statement.go +++ b/internal/eventstore/handler/v2/statement.go @@ -601,6 +601,12 @@ func NewCond(name string, value interface{}) Condition { } } +func NewUnequalCond(name string, value any) Condition { + return func(param string) (string, []any) { + return name + " <> " + param, []any{value} + } +} + func NewNamespacedCondition(name string, value interface{}) NamespacedCondition { return func(namespace string) Condition { return NewCond(namespace+"."+name, value) diff --git a/internal/query/projection/project_grant.go b/internal/query/projection/project_grant.go index 621623e061..d5a075c486 100644 --- a/internal/query/projection/project_grant.go +++ b/internal/query/projection/project_grant.go @@ -283,6 +283,7 @@ func (p *projectGrantProjection) reduceOwnerCorrected(event eventstore.Event) (* []handler.Condition{ handler.NewCond(ProjectGrantColumnInstanceID, event.Aggregate().InstanceID), handler.NewCond(ProjectGrantColumnProjectID, event.Aggregate().ID), + handler.NewUnequalCond(ProjectGrantColumnResourceOwner, event.Aggregate().ResourceOwner), }, ), nil }