Skip to content

Commit

Permalink
more [16]byte to uuid.UUID conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 6, 2024
1 parent 47cd0ee commit 3fa8eed
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions flow/connectors/postgres/qrep_query_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion flow/connectors/snowflake/avro_file_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion flow/connectors/sql/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions flow/model/qvalue/avro_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion flow/pua/peerdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3fa8eed

Please sign in to comment.