From e3d58d7733ca60895288287ebddab51161b3bc52 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Sun, 15 Sep 2024 12:44:04 -0400 Subject: [PATCH] Remove warning for an arrow referencing a relation in its own namespace This is less risky of causing issues than referencing an external relation, so disable the warning in this case --- pkg/development/warningdefs.go | 5 +++++ pkg/development/warnings_test.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/development/warningdefs.go b/pkg/development/warningdefs.go index cf5c9dae00..69c6176372 100644 --- a/pkg/development/warningdefs.go +++ b/pkg/development/warningdefs.go @@ -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 diff --git a/pkg/development/warnings_test.go b/pkg/development/warnings_test.go index 7385d6ba5e..398a2d50d2 100644 --- a/pkg/development/warnings_test.go +++ b/pkg/development/warnings_test.go @@ -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 {