Skip to content

Commit

Permalink
feat: support nested userset rewrites
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Jul 4, 2022
1 parent 5a2a501 commit af098e5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/check/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}

Expand All @@ -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,
Expand Down

0 comments on commit af098e5

Please sign in to comment.