فهرست منبع

Add support for "LexicalUUIDType".

Support it by treating it the same as UUIDType.

AFAIK originally there was LexicalUUIDType and TimeUUIDType. Lexical did
simple byte-wise comparison, where Time sorted using the UUID's time
value. UUIDType was added as a convenience type (CASSANDRA-2233) which
compares using the time value for time UUIDs, else byte-wise.
LexicalUUIDType was deprecated but not removed. We still have some
schema around explicitly using the LexicalUUIDType comparator.
Muir Manders 10 سال پیش
والد
کامیت
d2348c0775
2فایلهای تغییر یافته به همراه32 افزوده شده و 1 حذف شده
  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