From 3fa8eed0699f4ff5135519ec40521a30f7dfc8e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Fri, 6 Dec 2024 15:38:56 +0000 Subject: [PATCH] more [16]byte to uuid.UUID conversion --- flow/connectors/postgres/qrep_query_executor_test.go | 4 ++-- flow/connectors/snowflake/avro_file_writer_test.go | 2 +- flow/connectors/sql/query_executor.go | 2 +- flow/model/qvalue/avro_converter.go | 4 ++-- flow/pua/peerdb.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flow/connectors/postgres/qrep_query_executor_test.go b/flow/connectors/postgres/qrep_query_executor_test.go index f8f686c42f..eaa015c1cf 100644 --- a/flow/connectors/postgres/qrep_query_executor_test.go +++ b/flow/connectors/postgres/qrep_query_executor_test.go @@ -132,7 +132,7 @@ func TestAllDataTypes(t *testing.T) { "text", // col_text []byte("bytea"), // col_bytea `{"key": "value"}`, // col_json - savedUUID.String(), // col_uuid + savedUUID, // col_uuid savedTime, // col_timestamp "123.456", // col_numeric savedTime, // col_tz @@ -189,7 +189,7 @@ func TestAllDataTypes(t *testing.T) { expectedJSON := `{"key":"value"}` require.Equal(t, expectedJSON, record[7].Value(), "expected '{\"key\":\"value\"}'") - actualUUID := record[8].Value().([16]uint8) + actualUUID := record[8].Value().(uuid.UUID) require.Equal(t, savedUUID[:], actualUUID[:], "expected savedUUID: %v", savedUUID) actualTime := record[9].Value().(time.Time) require.Equal(t, savedTime.Truncate(time.Second), diff --git a/flow/connectors/snowflake/avro_file_writer_test.go b/flow/connectors/snowflake/avro_file_writer_test.go index 4a76fccd01..fbf86fc4c7 100644 --- a/flow/connectors/snowflake/avro_file_writer_test.go +++ b/flow/connectors/snowflake/avro_file_writer_test.go @@ -49,7 +49,7 @@ func createQValue(t *testing.T, kind qvalue.QValueKind, placeholder int) qvalue. case qvalue.QValueKindNumeric: return qvalue.QValueNumeric{Val: decimal.New(int64(placeholder), 1)} case qvalue.QValueKindUUID: - return qvalue.QValueUUID{Val: [16]byte(uuid.New())} // assuming you have the github.com/google/uuid package + return qvalue.QValueUUID{Val: uuid.New()} // assuming you have the github.com/google/uuid package case qvalue.QValueKindQChar: return qvalue.QValueQChar{Val: uint8(48 + placeholder%10)} // assuming you have the github.com/google/uuid package // case qvalue.QValueKindArray: diff --git a/flow/connectors/sql/query_executor.go b/flow/connectors/sql/query_executor.go index fb94280c38..4be60f4a51 100644 --- a/flow/connectors/sql/query_executor.go +++ b/flow/connectors/sql/query_executor.go @@ -443,7 +443,7 @@ func toQValue(kind qvalue.QValueKind, val interface{}) (qvalue.QValue, error) { if err != nil { return nil, fmt.Errorf("failed to parse uuid: %v", *v) } - return qvalue.QValueUUID{Val: [16]byte(uuidVal)}, nil + return qvalue.QValueUUID{Val: uuidVal}, nil } case qvalue.QValueKindJSON: diff --git a/flow/model/qvalue/avro_converter.go b/flow/model/qvalue/avro_converter.go index 6cf5b01856..80c8d9b822 100644 --- a/flow/model/qvalue/avro_converter.go +++ b/flow/model/qvalue/avro_converter.go @@ -606,8 +606,8 @@ func (c *QValueAvroConverter) processHStore(hstore string) (interface{}, error) return jsonString, nil } -func (c *QValueAvroConverter) processUUID(byteData [16]byte) interface{} { - uuidString := uuid.UUID(byteData).String() +func (c *QValueAvroConverter) processUUID(byteData uuid.UUID) interface{} { + uuidString := byteData.String() if c.Nullable { return goavro.Union("string", uuidString) } diff --git a/flow/pua/peerdb.go b/flow/pua/peerdb.go index 6279cb960a..b437232b97 100644 --- a/flow/pua/peerdb.go +++ b/flow/pua/peerdb.go @@ -241,7 +241,7 @@ func LuaRowNewIndex(ls *lua.LState) int { case qvalue.QValueKindUUID: if ud, ok := val.(*lua.LUserData); ok { if id, ok := ud.Value.(uuid.UUID); ok { - newqv = qvalue.QValueUUID{Val: [16]byte(id)} + newqv = qvalue.QValueUUID{Val: id} } } case qvalue.QValueKindArrayUUID: