mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
Merge pull request #1685 from prometheus/beorn7/fix-group
Correctly stringify GROUP_x modifiers without labels
This commit is contained in:
commit
3113c0d719
|
@ -165,11 +165,16 @@ func (node *BinaryExpr) String() string {
|
||||||
} else {
|
} else {
|
||||||
matching = fmt.Sprintf(" ON(%s)", vm.MatchingLabels)
|
matching = fmt.Sprintf(" ON(%s)", vm.MatchingLabels)
|
||||||
}
|
}
|
||||||
if vm.Card == CardManyToOne {
|
if vm.Card == CardManyToOne || vm.Card == CardOneToMany {
|
||||||
matching += fmt.Sprintf(" GROUP_LEFT(%s)", vm.Include)
|
matching += " GROUP_"
|
||||||
}
|
if vm.Card == CardManyToOne {
|
||||||
if vm.Card == CardOneToMany {
|
matching += "LEFT"
|
||||||
matching += fmt.Sprintf(" GROUP_RIGHT(%s)", vm.Include)
|
} else {
|
||||||
|
matching += "RIGHT"
|
||||||
|
}
|
||||||
|
if len(vm.Include) > 0 {
|
||||||
|
matching += fmt.Sprintf("(%s)", vm.Include)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s %s%s%s %s", node.LHS, node.Op, returnBool, matching, node.RHS)
|
return fmt.Sprintf("%s %s%s%s %s", node.LHS, node.Op, returnBool, matching, node.RHS)
|
||||||
|
|
|
@ -39,6 +39,15 @@ func TestExprString(t *testing.T) {
|
||||||
{
|
{
|
||||||
in: `a - ON(b) c`,
|
in: `a - ON(b) c`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: `a - ON(b) GROUP_LEFT(x) c`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: `a - ON(b) GROUP_LEFT(x, y) c`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: `a - ON(b) GROUP_LEFT c`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
in: `a - IGNORING(b) c`,
|
in: `a - IGNORING(b) c`,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue