@@ -17,6 +17,7 @@ import (
17
17
"fmt"
18
18
"io"
19
19
"math"
20
+ "strconv"
20
21
"time"
21
22
)
22
23
@@ -834,7 +835,8 @@ func (rows *textRows) readRow(dest []driver.Value) error {
834
835
835
836
for i := range dest {
836
837
// Read bytes and convert to string
837
- dest [i ], isNull , n , err = readLengthEncodedString (data [pos :])
838
+ var buf []byte
839
+ buf , isNull , n , err = readLengthEncodedString (data [pos :])
838
840
pos += n
839
841
840
842
if err != nil {
@@ -846,19 +848,40 @@ func (rows *textRows) readRow(dest []driver.Value) error {
846
848
continue
847
849
}
848
850
849
- if ! mc .parseTime {
850
- continue
851
- }
852
-
853
- // Parse time field
854
851
switch rows .rs .columns [i ].fieldType {
855
852
case fieldTypeTimestamp ,
856
853
fieldTypeDateTime ,
857
854
fieldTypeDate ,
858
855
fieldTypeNewDate :
859
- if dest [i ], err = parseDateTime (dest [i ].([]byte ), mc .cfg .Loc ); err != nil {
860
- return err
856
+ if mc .parseTime {
857
+ dest [i ], err = parseDateTime (buf , mc .cfg .Loc )
858
+ } else {
859
+ dest [i ] = buf
860
+ }
861
+
862
+ case fieldTypeTiny , fieldTypeShort , fieldTypeInt24 , fieldTypeYear , fieldTypeLong :
863
+ dest [i ], err = strconv .ParseInt (string (buf ), 10 , 32 )
864
+
865
+ case fieldTypeLongLong :
866
+ if rows .rs .columns [i ].flags & flagUnsigned != 0 {
867
+ dest [i ], err = strconv .ParseUint (string (buf ), 10 , 64 )
868
+ } else {
869
+ dest [i ], err = strconv .ParseInt (string (buf ), 10 , 64 )
861
870
}
871
+
872
+ case fieldTypeFloat :
873
+ var d float64
874
+ d , err = strconv .ParseFloat (string (buf ), 32 )
875
+ dest [i ] = float32 (d )
876
+
877
+ case fieldTypeDouble :
878
+ dest [i ], err = strconv .ParseFloat (string (buf ), 64 )
879
+
880
+ default :
881
+ dest [i ] = buf
882
+ }
883
+ if err != nil {
884
+ return err
862
885
}
863
886
}
864
887
0 commit comments