Skip to content

Commit

Permalink
marshall: allow unmarshalling into nil byte slice (apache#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel authored Aug 12, 2017
1 parent 44be8dc commit 6563b45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 3 additions & 4 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,11 @@ func unmarshalVarchar(info TypeInfo, data []byte, value interface{}) error {
*v = string(data)
return nil
case *[]byte:
var dataCopy []byte
if data != nil {
dataCopy = make([]byte, len(data))
copy(dataCopy, data)
*v = copyBytes(data)
} else {
*v = nil
}
*v = dataCopy
return nil
}
rv := reflect.ValueOf(value)
Expand Down
7 changes: 7 additions & 0 deletions marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,13 @@ var marshalTests = []struct {
nil,
nil,
},
{
NativeType{proto: 2, typ: TypeBlob},
[]byte(nil),
([]byte)(nil),
nil,
nil,
},
}

func decimalize(s string) *inf.Dec {
Expand Down

0 comments on commit 6563b45

Please sign in to comment.