diff --git a/CHANGELOG.md b/CHANGELOG.md index bed4bea..efea53b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## v2.0.2 - 2019-06-28 + +### Fixed + - Fix blob types in primary keys not being comparable + ## v2.0.1 - 2019-06-28 ### Changed diff --git a/README.md b/README.md index e2e27de..394e752 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ gocassa Gocassa is a high-level library on top of [gocql](https://github.com/gocql/gocql). -Current version: v2.0.0 +Current version: v2.0.2 Compared to gocql it provides query building, adds data binding, and provides easy-to-use "recipe" tables for common query use-cases. Unlike [cqlc](https://github.com/relops/cqlc), it does not use code generation. diff --git a/relation.go b/relation.go index c7c129f..cbd7dc3 100644 --- a/relation.go +++ b/relation.go @@ -56,6 +56,16 @@ func convertToPrimitive(i interface{}) interface{} { return v.UnixNano() case time.Duration: return v.Nanoseconds() + case []byte: + // This case works as strings in Go are simply defined as the following: + // "A string value is a (possibly empty) sequence of bytes" (from the go lang spec) + // and + // "Converting a slice of bytes to a string type yields a string whose successive bytes are the elements of the slice." + // Finally: + // "String values are comparable and ordered, lexically byte-wise." + // We mostly want this to allow comparisons of blob types in the primary key of a table, + // since []byte are not `==` comparable in go, but strings are + return string(v) default: return i } diff --git a/relation_test.go b/relation_test.go index 9492b30..cbcee47 100644 --- a/relation_test.go +++ b/relation_test.go @@ -18,6 +18,7 @@ func TestAnyEquals(t *testing.T) { {time.Minute * 2, makeInterfaceArray(time.Second * 120)}, {testTime1, makeInterfaceArray(testTime2)}, {1950, makeInterfaceArray(1950)}, + {[]byte{0x00, 0xFF, 0x01, 0x99, 0xEA}, makeInterfaceArray("\x00\xFF\x01\x99\xEA")}, } for _, tc := range testCases {