From af098e56e6d41eb3d4517bfd777530c593d9802f Mon Sep 17 00:00:00 2001 From: hperl <34397+hperl@users.noreply.github.com> Date: Mon, 4 Jul 2022 15:54:31 +0200 Subject: [PATCH] feat: support nested userset rewrites --- internal/check/engine.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/check/engine.go b/internal/check/engine.go index ed3fbabcf..facbfd534 100644 --- a/internal/check/engine.go +++ b/internal/check/engine.go @@ -255,6 +255,11 @@ func (e *Engine) checkUsersetRewrite( Tuple: *r, Type: expand.ComputedUserset, }, e.checkComputedUserset(ctx, r, c, restDepth))) + case *ast.UsersetRewrite: + checks = append(checks, checkgroup.WithEdge(checkgroup.Edge{ + Tuple: *r, + Type: toExpandNodeType(c.Operation), + }, e.checkUsersetRewrite(ctx, r, c, restDepth))) } } @@ -263,6 +268,19 @@ func (e *Engine) checkUsersetRewrite( } } +func toExpandNodeType(op ast.SetOperation) expand.NodeType { + switch op { + case ast.SetOperationUnion: + return expand.Union + case ast.SetOperationDifference: + return expand.Exclusion + case ast.SetOperationIntersection: + return expand.Intersection + default: + return expand.Union + } +} + func (e *Engine) checkComputedUserset( ctx context.Context, r *RelationTuple,