@@ -41,7 +41,6 @@ type table struct {
41
41
42
42
data * Data
43
43
rows * sql.Rows
44
- types []reflect.Type
45
44
values []interface {}
46
45
}
47
46
@@ -53,7 +52,7 @@ type metaData struct {
53
52
54
53
const (
55
54
// Version of this plugin for easy reference
56
- Version = "0.5.0 "
55
+ Version = "0.5.1 "
57
56
58
57
defaultMaxAllowedPacket = 4194304
59
58
)
@@ -302,7 +301,7 @@ func (table *table) CreateSQL() (string, error) {
302
301
}
303
302
304
303
func (table * table ) Init () (err error ) {
305
- if len (table .types ) != 0 {
304
+ if len (table .values ) != 0 {
306
305
return errors .New ("can't init twice" )
307
306
}
308
307
@@ -324,22 +323,22 @@ func (table *table) Init() (err error) {
324
323
return err
325
324
}
326
325
327
- table . types = make ([] reflect.Type , len ( tt ))
326
+ var t reflect.Type
328
327
table .values = make ([]interface {}, len (tt ))
329
328
for i , tp := range tt {
330
329
st := tp .ScanType ()
331
330
if tp .DatabaseTypeName () == "BLOB" {
332
- table . types [ i ] = reflect .TypeOf (sql.RawBytes {})
331
+ t = reflect .TypeOf (sql.RawBytes {})
333
332
} else if st != nil && (st .Kind () == reflect .Int ||
334
333
st .Kind () == reflect .Int8 ||
335
334
st .Kind () == reflect .Int16 ||
336
335
st .Kind () == reflect .Int32 ||
337
336
st .Kind () == reflect .Int64 ) {
338
- table . types [ i ] = reflect .TypeOf (sql.NullInt64 {})
337
+ t = reflect .TypeOf (sql.NullInt64 {})
339
338
} else {
340
- table . types [ i ] = reflect .TypeOf (sql.NullString {})
339
+ t = reflect .TypeOf (sql.NullString {})
341
340
}
342
- table .values [i ] = reflect .New (table . types [ i ] ).Interface ()
341
+ table .values [i ] = reflect .New (t ).Interface ()
343
342
}
344
343
return nil
345
344
}
0 commit comments