Skip to content

Commit

Permalink
Remove warning for an arrow referencing a relation in its own namespace
Browse files Browse the repository at this point in the history
This is less risky of causing issues than referencing an external relation, so disable the warning in this case
  • Loading branch information
josephschorr committed Sep 15, 2024
1 parent e629448 commit 30314f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/development/warningdefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ var lintArrowReferencingRelation = ttuCheck{
}

for _, subjectType := range allowedSubjectTypes {
// Skip for arrow referencing relations in the same namespace.
if subjectType.Namespace == ts.Namespace().Name {
continue
}

nts, err := ts.TypeSystemForNamespace(ctx, subjectType.Namespace)
if err != nil {
return nil, err
Expand Down
12 changes: 12 additions & 0 deletions pkg/development/warnings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ func TestWarnings(t *testing.T) {
SourceCode: "view",
},
},
{
name: "arrow referencing relation in the same namespace",
schema: `definition user {}
definition document {
relation parent: document
relation viewer: user
permission view = parent->viewer
}
`,
expectedWarning: nil,
},
}

for _, tc := range tcs {
Expand Down

0 comments on commit 30314f4

Please sign in to comment.