Skip to content

Commit

Permalink
Merge pull request #1287 from nyaruka/contactql_inspect_fix
Browse files Browse the repository at this point in the history
Fix inspection of contact queries using `group = ""` or `group != ""`
  • Loading branch information
rowanseymour authored Sep 30, 2024
2 parents a005ed7 + df03be1 commit 27e1fc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contactql/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
11 changes: 11 additions & 0 deletions contactql/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 27e1fc0

Please sign in to comment.