Skip to content

Commit

Permalink
When tag value is set to null in AddTags, treat as removal (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-quix authored Feb 13, 2024
1 parent a689b55 commit 4e1dd40
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public void AddTags_NullAndEmptyTags_ShouldNotThrowException()
tsdts.AddTag("test2", "val5");
tsdts.AddTags(null);
tsdts.AddTags(new Dictionary<string, string>());
tsdts.AddTag("test5", "willgetdeleted");
tsdts.AddTags(new Dictionary<string, string>()
{
{"test5", null}
});

// Assert
tsdts.Tags.Count.Should().Be(2);
Expand Down
3 changes: 2 additions & 1 deletion src/QuixStreams.Streaming/Models/EventData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public EventData AddTags(IEnumerable<KeyValuePair<string, string>> tags)

foreach (var tagPair in tags)
{
this.AddTag(tagPair.Key, tagPair.Value);
if (string.IsNullOrEmpty(tagPair.Value)) this.RemoveTag(tagPair.Key);
else this.AddTag(tagPair.Key, tagPair.Value);
}

return this;
Expand Down
3 changes: 2 additions & 1 deletion src/QuixStreams.Streaming/Models/TimeseriesDataTimestamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ public TimeseriesDataTimestamp AddTags(IEnumerable<KeyValuePair<string, string>>

foreach (var tagPair in tags)
{
this.AddTag(tagPair.Key, tagPair.Value);
if (string.IsNullOrEmpty(tagPair.Value)) this.RemoveTag(tagPair.Key);
else this.AddTag(tagPair.Key, tagPair.Value);
}

return this;
Expand Down

0 comments on commit 4e1dd40

Please sign in to comment.