Skip to content

Commit

Permalink
fix bool attribute equality
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeroberts-wk committed Jul 21, 2021
1 parent f1d4497 commit f895196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions model/pdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ func (a AttributeValue) Equal(av AttributeValue) bool {
return a.orig.Value == av.orig.Value
}

if a.Type() != av.Type() {
return false
}

switch v := a.orig.Value.(type) {
case *otlpcommon.AnyValue_StringValue:
return v.StringValue == av.orig.GetStringValue()
Expand Down
6 changes: 3 additions & 3 deletions model/pdata/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ func TestAttributeValueEqual(t *testing.T) {
av1 = NewAttributeValueDouble(123)
assert.True(t, av1.Equal(av2))

av2 = NewAttributeValueBool(true)
av2 = NewAttributeValueBool(false)
assert.False(t, av1.Equal(av2))
assert.False(t, av2.Equal(av1))

av1 = NewAttributeValueBool(true)
assert.True(t, av1.Equal(av2))
assert.False(t, av1.Equal(av2))

av1 = NewAttributeValueBool(false)
assert.False(t, av1.Equal(av2))
assert.True(t, av1.Equal(av2))

av1 = NewAttributeValueArray()
av1.ArrayVal().AppendEmpty().SetIntVal(123)
Expand Down

0 comments on commit f895196

Please sign in to comment.