From df03be18b2c4287a4cf702060e75143e6051b97b Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Mon, 30 Sep 2024 17:42:41 -0500 Subject: [PATCH] Fix inspection of contact queries using group = "" or group != "" --- contactql/inspect.go | 2 +- contactql/inspect_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contactql/inspect.go b/contactql/inspect.go index 28a3bd88f..85e1c4864 100644 --- a/contactql/inspect.go +++ b/contactql/inspect.go @@ -36,7 +36,7 @@ func Inspect(query *ContactQuery) *Inspection { case PropertyTypeAttribute: attributes[c.propKey] = true - if c.propKey == AttributeGroup { + if c.propKey == AttributeGroup && c.value != "" { if query.resolver != nil { group := query.resolver.ResolveGroup(c.value) addRef(assets.NewGroupReference(group.UUID(), group.Name())) diff --git a/contactql/inspect_test.go b/contactql/inspect_test.go index 819decd24..ccfcbcdf1 100644 --- a/contactql/inspect_test.go +++ b/contactql/inspect_test.go @@ -102,6 +102,17 @@ func TestInspect(t *testing.T) { AllowAsGroup: false, }, }, + { + query: "group = \"\"", // group presence parsed with resolver + resolver: resolver, + inspection: &contactql.Inspection{ + Attributes: []string{"group"}, + Schemes: []string{}, + Fields: []*assets.FieldReference{}, + Groups: []*assets.GroupReference{}, + AllowAsGroup: false, + }, + }, } for _, tc := range tests {