Vanillaxi commented on code in PR #1141:
URL: 
https://github.com/apache/incubator-seata-go/pull/1141#discussion_r3868200413


##########
pkg/datasource/sql/undo/parser/parser_protobuf.go:
##########
@@ -244,6 +246,55 @@ func convertAnyToInterface(anyValue *any.Any) 
(interface{}, error) {
        return value, nil
 }
 
+func convertAnyToColumnValue(anyValue *any.Any, columnType types.JDBCType) 
(interface{}, error) {
+       bytesValue := &wrappers.BytesValue{}
+       if err := anypb.UnmarshalTo(anyValue, bytesValue, 
proto.UnmarshalOptions{}); err != nil {
+               return nil, err
+       }
+       if bytes.Equal(bytesValue.Value, []byte("null")) {
+               return nil, nil
+       }
+
+       switch columnType {
+       case types.JDBCTypeReal, types.JDBCTypeDecimal, types.JDBCTypeDouble,
+               types.JDBCTypeTinyInt, types.JDBCTypeSmallInt, 
types.JDBCTypeInteger, types.JDBCTypeBigInt:
+               decoder := json.NewDecoder(bytes.NewReader(bytesValue.Value))
+               decoder.UseNumber()
+               var value json.Number
+               if err := decoder.Decode(&value); err != nil {
+                       return nil, err
+               }
+               switch columnType {
+               case types.JDBCTypeReal:
+                       parsed, err := strconv.ParseFloat(value.String(), 32)
+                       return float32(parsed), err
+               case types.JDBCTypeDecimal, types.JDBCTypeDouble:
+                       return strconv.ParseFloat(value.String(), 64)
+               case types.JDBCTypeTinyInt:
+                       parsed, err := strconv.ParseInt(value.String(), 10, 8)

Review Comment:
   Thanks, I retained the type as `int64`/`uint64` and added tests in the 
latest update.



-- 
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]

Reply via email to