Skip to content

Commit 38ef509

Browse files
authored
Merge pull request jamf#7 from BrandonRoehl/dont-need-to-store-the-reflection-type
Dont need to store the reflection type
2 parents f25e26f + 4f247b0 commit 38ef509

File tree

3 files changed

+7
-49
lines changed

3 files changed

+7
-49
lines changed

Gopkg.lock

Lines changed: 0 additions & 15 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 26 deletions
This file was deleted.

dump.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type table struct {
4141

4242
data *Data
4343
rows *sql.Rows
44-
types []reflect.Type
4544
values []interface{}
4645
}
4746

@@ -53,7 +52,7 @@ type metaData struct {
5352

5453
const (
5554
// Version of this plugin for easy reference
56-
Version = "0.5.0"
55+
Version = "0.5.1"
5756

5857
defaultMaxAllowedPacket = 4194304
5958
)
@@ -302,7 +301,7 @@ func (table *table) CreateSQL() (string, error) {
302301
}
303302

304303
func (table *table) Init() (err error) {
305-
if len(table.types) != 0 {
304+
if len(table.values) != 0 {
306305
return errors.New("can't init twice")
307306
}
308307

@@ -324,22 +323,22 @@ func (table *table) Init() (err error) {
324323
return err
325324
}
326325

327-
table.types = make([]reflect.Type, len(tt))
326+
var t reflect.Type
328327
table.values = make([]interface{}, len(tt))
329328
for i, tp := range tt {
330329
st := tp.ScanType()
331330
if tp.DatabaseTypeName() == "BLOB" {
332-
table.types[i] = reflect.TypeOf(sql.RawBytes{})
331+
t = reflect.TypeOf(sql.RawBytes{})
333332
} else if st != nil && (st.Kind() == reflect.Int ||
334333
st.Kind() == reflect.Int8 ||
335334
st.Kind() == reflect.Int16 ||
336335
st.Kind() == reflect.Int32 ||
337336
st.Kind() == reflect.Int64) {
338-
table.types[i] = reflect.TypeOf(sql.NullInt64{})
337+
t = reflect.TypeOf(sql.NullInt64{})
339338
} else {
340-
table.types[i] = reflect.TypeOf(sql.NullString{})
339+
t = reflect.TypeOf(sql.NullString{})
341340
}
342-
table.values[i] = reflect.New(table.types[i]).Interface()
341+
table.values[i] = reflect.New(t).Interface()
343342
}
344343
return nil
345344
}

0 commit comments

Comments
 (0)