Skip to content

Commit

Permalink
fix interneals
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick <[email protected]>
  • Loading branch information
Patrick0308 committed Oct 17, 2023
1 parent a82b8a0 commit c950a9e
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions sdk/go/mysql/internals.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ func fromOutboundMysqlDbValue(x C.outbound_mysql_db_value_t) (any, error) {
case dbValueStr:
str := (*C.outbound_mysql_string_t)(unsafe.Pointer(&x.val))
return C.GoStringN(str.ptr, C.int(str.len)), nil
case dbValueNull:
return nil, nil
case dbValueUnsupported:
return nil, errors.New("db return value type unsupported")
}
return nil, nil
return nil, errors.New("db return value unknown type")
}

const (
Expand Down Expand Up @@ -212,13 +214,25 @@ func toOutboundMysqlParameterValue(x any) C.outbound_mysql_parameter_value_t {
*(*C.int32_t)(unsafe.Pointer(&ret.val)) = int32(v)
ret.tag = paramValueInt32
case int64:
*(*C.int64_t)(unsafe.Pointer(&ret.val)) = v
*(*C.int64_t)(unsafe.Pointer(&ret.val)) = int64(v)
ret.tag = paramValueInt64
case uint8:
*(*C.uint8_t)(unsafe.Pointer(&ret.val)) = uint8(v)
ret.tag = paramValueUint8
case uint16:
*(*C.uint16_t)(unsafe.Pointer(&ret.val)) = uint16(v)
ret.tag = paramValueUint16
case uint32:
*(*C.uint32_t)(unsafe.Pointer(&ret.val)) = uint32(v)
ret.tag = paramValueUint32
case uint64:
*(*C.uint64_t)(unsafe.Pointer(&ret.val)) = uint64(v)
ret.tag = paramValueUint64
case float32:
*(*C.float)(unsafe.Pointer(&ret.val)) = v
*(*C.float)(unsafe.Pointer(&ret.val)) = float32(v)
ret.tag = paramValueFloat32
case float64:
*(*C.double)(unsafe.Pointer(&ret.val)) = v
*(*C.double)(unsafe.Pointer(&ret.val)) = float64(v)
ret.tag = paramValueFloat64
case string:
str := outboundMysqlStr(v)
Expand Down Expand Up @@ -288,15 +302,15 @@ func colTypeToReflectType(typ uint8) reflect.Type {
case dbDataTypeInt32:
return reflect.TypeOf(int32(0))
case dbDataTypeInt64:
return reflect.TypeOf(int32(0))
return reflect.TypeOf(int64(0))
case dbDataTypeUint8:
return reflect.TypeOf(uint8(0))
case dbDataTypeUint16:
return reflect.TypeOf(uint16(0))
case dbDataTypeUint32:
return reflect.TypeOf(uint32(0))
case dbDataTypeUint64:
return reflect.TypeOf(uint32(0))
return reflect.TypeOf(uint64(0))
case dbDataTypeStr:
return reflect.TypeOf("")
case dbDataTypeBinary:
Expand Down

0 comments on commit c950a9e

Please sign in to comment.