Skip to content

Commit

Permalink
Merge pull request #14296 from colega/fix-matcher-string-with-empty-l…
Browse files Browse the repository at this point in the history
…abel-name

Fix `Matcher.String()` with empty label name
  • Loading branch information
bboreham authored Jun 19, 2024
2 parents f45b0fd + 6685cbc commit 5c41768
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion model/labels/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (m *Matcher) shouldQuoteName() bool {
}
return true
}
return false
return len(m.Name) == 0
}

// Matches returns whether the matcher matches the given string value.
Expand Down
7 changes: 7 additions & 0 deletions promql/parser/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ func TestExprString(t *testing.T) {
in: `{"_0"="1"}`,
out: `{_0="1"}`,
},
{
in: `{""="0"}`,
},
{
in: "{``=\"0\"}",
out: `{""="0"}`,
},
}

for _, test := range inputs {
Expand Down

0 comments on commit 5c41768

Please sign in to comment.