@@ -52,28 +52,24 @@ func (r *RowsEvent) handleUnsigned() {
52
52
}
53
53
54
54
for i := 0 ; i < len (r .Rows ); i ++ {
55
- for _ , index := range r .Table .UnsignedColumns {
56
- switch t := r.Rows [i ][index ].(type ) {
55
+ for _ , columnIdx := range r .Table .UnsignedColumns {
56
+ switch value := r.Rows [i ][columnIdx ].(type ) {
57
57
case int8 :
58
- r.Rows [i ][index ] = uint8 (t )
58
+ r.Rows [i ][columnIdx ] = uint8 (value )
59
59
case int16 :
60
- r.Rows [i ][index ] = uint16 (t )
60
+ r.Rows [i ][columnIdx ] = uint16 (value )
61
61
case int32 :
62
- if r .Table .Columns [index ].Type == schema .TYPE_MEDIUM_INT {
63
- // problem with mediumint is that it's a 3-byte type. There is no compatible golang type to match that.
64
- // So to convert from negative to positive we'd need to convert the value manually
65
- if t >= 0 {
66
- r.Rows [i ][index ] = uint32 (t )
67
- } else {
68
- r.Rows [i ][index ] = uint32 (maxMediumintUnsigned + t + 1 )
69
- }
62
+ // problem with mediumint is that it's a 3-byte type. There is no compatible golang type to match that.
63
+ // So to convert from negative to positive we'd need to convert the value manually
64
+ if value < 0 && r .Table .Columns [columnIdx ].Type == schema .TYPE_MEDIUM_INT {
65
+ r.Rows [i ][columnIdx ] = uint32 (maxMediumintUnsigned + value + 1 )
70
66
} else {
71
- r.Rows [i ][index ] = uint32 (t )
67
+ r.Rows [i ][columnIdx ] = uint32 (value )
72
68
}
73
69
case int64 :
74
- r.Rows [i ][index ] = uint64 (t )
70
+ r.Rows [i ][columnIdx ] = uint64 (value )
75
71
case int :
76
- r.Rows [i ][index ] = uint (t )
72
+ r.Rows [i ][columnIdx ] = uint (value )
77
73
default :
78
74
// nothing to do
79
75
}
0 commit comments