Skip to content

Commit

Permalink
Bug fix: Add matching case for nil uuid column
Browse files Browse the repository at this point in the history
Schemagen generates structs as [16]byte for uuid and timeuuid columns. 

when a time/uuid column has nil value, the switch case will not match with *[]byte and returns the following error:

`can not unmarshal X timeuuid into *[16]uint8`

to solve this we can change Schemagen, or add the case here. personally I belive changing Schemagen has more cost and mapping UUIDs to [16]byte is better than mapping to []byte.
  • Loading branch information
izenhaim authored Aug 19, 2024
1 parent f9e730e commit e47a73b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,8 @@ func unmarshalUUID(info TypeInfo, data []byte, value interface{}) error {
*v = ""
case *[]byte:
*v = nil
case *[16]byte:
*v = [16]byte{}
case *UUID:
*v = UUID{}
default:
Expand Down

0 comments on commit e47a73b

Please sign in to comment.