Skip to content

Commit

Permalink
Fixing bug that meant printing a vector matching expression with matc…
Browse files Browse the repository at this point in the history
…her labels would incorrectly not include empty parenthesis for group_right/ group_left (#10)

Co-authored-by: James Luck <[email protected]>
  • Loading branch information
djluck and djluck authored Aug 29, 2022
1 parent 2575ca7 commit 2e6cf0e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/PromQL.Parser/Printer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public virtual void Visit(VectorMatching vm)
_sb.Append(vm.MatchCardinality.ToPromQl());
}

if (vm.Include.Length > 0)
if (vm.Include.Length > 0 || vm.MatchCardinality != VectorMatching.DefaultMatchCardinality)
{
if (_sb.Length > 0)
_sb.Append(" ");
Expand Down
2 changes: 1 addition & 1 deletion tests/PromQL.Parser.Tests/PrinterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void VectorMatching_GroupRight_NoLabels_ToPromQl()
false,
ImmutableArray<string>.Empty,
false
)).Should().Be("group_right");
)).Should().Be("group_right ()");
}

[Test]
Expand Down

0 comments on commit 2e6cf0e

Please sign in to comment.