lib/promrelabel: return correct string representation for IfExpression containing a single selector

This is a follow-up for 62651570bb

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4635
This commit is contained in:
Aliaksandr Valialkin 2023-07-24 19:30:47 -07:00
parent 56c17d16f6
commit ad08d9c884
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -141,7 +141,10 @@ func newIfExpression(s string) (*ifExpression, error) {
// String returns string representation of ie. // String returns string representation of ie.
func (ie *IfExpression) String() string { func (ie *IfExpression) String() string {
if ie == nil { if ie == nil {
return "[]" return "{}"
}
if len(ie.ies) == 1 {
return ie.ies[0].String()
} }
return fmt.Sprintf("%s", ie.ies) return fmt.Sprintf("%s", ie.ies)
} }