Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warning for an arrow referencing a relation in its own namespace #2062

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading