joao-r-reis commented on code in PR #1855:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1855#discussion_r2132353986
##########
marshal.go:
##########
@@ -232,95 +176,97 @@ func Unmarshal(info TypeInfo, data []byte, value
interface{}) error {
return v.UnmarshalCQL(info, data)
}
- if isNullableValue(value) {
- return unmarshalNullable(info, data, value)
- }
-
- switch info.Type() {
- case TypeVarchar, TypeAscii, TypeBlob, TypeText:
- return unmarshalVarchar(info, data, value)
- case TypeBoolean:
- return unmarshalBool(info, data, value)
- case TypeInt:
- return unmarshalInt(info, data, value)
- case TypeBigInt, TypeCounter:
- return unmarshalBigInt(info, data, value)
- case TypeVarint:
- return unmarshalVarint(info, data, value)
- case TypeSmallInt:
- return unmarshalSmallInt(info, data, value)
- case TypeTinyInt:
- return unmarshalTinyInt(info, data, value)
- case TypeFloat:
- return unmarshalFloat(info, data, value)
- case TypeDouble:
- return unmarshalDouble(info, data, value)
- case TypeDecimal:
- return unmarshalDecimal(info, data, value)
- case TypeTime:
- return unmarshalTime(info, data, value)
- case TypeTimestamp:
- return unmarshalTimestamp(info, data, value)
- case TypeList, TypeSet:
- return unmarshalList(info, data, value)
- case TypeMap:
- return unmarshalMap(info, data, value)
- case TypeTimeUUID:
- return unmarshalTimeUUID(info, data, value)
- case TypeUUID:
- return unmarshalUUID(info, data, value)
- case TypeInet:
- return unmarshalInet(info, data, value)
- case TypeTuple:
- return unmarshalTuple(info, data, value)
- case TypeUDT:
- return unmarshalUDT(info, data, value)
- case TypeDate:
- return unmarshalDate(info, data, value)
- case TypeDuration:
- return unmarshalDuration(info, data, value)
- case TypeCustom:
- if vector, ok := info.(VectorType); ok {
- return unmarshalVector(vector, data, value)
+ // check for pointer
+ // we don't error for non-pointers because certain types support
unmarshalling
+ // into maps/slices
+ valueRef := reflect.ValueOf(value)
+ if valueRef.Kind() == reflect.Ptr {
+ // handle pointers and nil data
+ valueElemRef := valueRef.Elem()
+ switch valueElemRef.Kind() {
+ case reflect.Ptr:
+ if data == nil {
+ if valueElemRef.IsNil() {
+ return nil
+ }
+
valueRef.Elem().Set(reflect.Zero(valueElemRef.Type()))
+ return nil
+ }
+ // TODO: can we do this?
Review Comment:
discussed offline but yeah I think we should probably not change that
behavior just to be safe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]