Browse Source

Merge pull request #473 from retailnext/support-lexical-uuid-type

Add support for "LexicalUUIDType".
Chris Bannister 10 years ago
parent
commit
2641ef08fa
2 changed files with 32 additions and 1 deletions
  1. 31 0
      cassandra_test.go
  2. 1 1
      helpers.go

+ 31 - 0
cassandra_test.go

@@ -2126,3 +2126,34 @@ func TestManualQueryPaging(t *testing.T) {
 		t.Fatalf("expected to fetch %d rows got %d", fetched, rowsToInsert)
 	}
 }
+
+func TestLexicalUUIDType(t *testing.T) {
+	session := createSession(t)
+	defer session.Close()
+
+	if err := createTable(session, `CREATE TABLE test_lexical_uuid (
+			key     varchar,
+			column1 'org.apache.cassandra.db.marshal.LexicalUUIDType',
+			value   int,
+			PRIMARY KEY (key, column1)
+		)`); err != nil {
+		t.Fatal("create:", err)
+	}
+
+	key := TimeUUID().String()
+	column1 := TimeUUID()
+
+	err := session.Query("INSERT INTO test_lexical_uuid(key, column1, value) VALUES(?, ?, ?)", key, column1, 55).Exec()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var gotUUID UUID
+	if err := session.Query("SELECT column1 from test_lexical_uuid where key = ? AND column1 = ?", key, column1).Scan(&gotUUID); err != nil {
+		t.Fatal(err)
+	}
+
+	if gotUUID != column1 {
+		t.Errorf("got %s, expected %s", gotUUID, column1)
+	}
+}

+ 1 - 1
helpers.go

@@ -83,7 +83,7 @@ func getApacheCassandraType(class string) Type {
 		return TypeInt
 	case "DateType", "TimestampType":
 		return TypeTimestamp
-	case "UUIDType":
+	case "UUIDType", "LexicalUUIDType":
 		return TypeUUID
 	case "UTF8Type":
 		return TypeVarchar