Blob equals issue
msosnicki opened this issue · 4 comments
Currently Blob
has three variants, two of which define equals
in the following way:
override def equals(other: Any): Boolean = {
other.isInstanceOf[ByteBufferBlob] &&
buf.compareTo(other.asInstanceOf[ByteBufferBlob].buf) == 0
}
meaning that ArraySliceBlob
will never be equal to ByteBufferBlob
.
In addition to that, QueueBlob
does not define equals
and hashCode
at all.
The absence of equals
and hashCode
in QueueBlob is indeed a bug.
However, the fact that equals
takes into consideration the underlying structure is by design. If you're looking to compare the bytes of two blobs, you should use sameBytesAs
Do you have an example of scenario where it is useful to know the exact underlying type of a Blob
and take it into consideration when using equals
? Noticed that the types themselves are not hidden as well, so it's visible now that it didn't happen by accident. Thanks
I suppose we could implement the equals method using sameBytesAs, it would be less of a surprising behaviour for users. Comparisons that need to be structure aware can inspect the structure.
PR away, if you want
Ok, will raise one today