Skip to content

Commit

Permalink
Merge pull request #7 from BrandonRoehl/dont-need-to-store-the-reflec…
Browse files Browse the repository at this point in the history
…tion-type

Dont need to store the reflection type
  • Loading branch information
BrandonRoehl authored Oct 9, 2019
2 parents f25e26f + 4f247b0 commit 38ef509
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 49 deletions.
15 changes: 0 additions & 15 deletions Gopkg.lock

This file was deleted.

26 changes: 0 additions & 26 deletions Gopkg.toml

This file was deleted.

15 changes: 7 additions & 8 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type table struct {

data *Data
rows *sql.Rows
types []reflect.Type
values []interface{}
}

Expand All @@ -53,7 +52,7 @@ type metaData struct {

const (
// Version of this plugin for easy reference
Version = "0.5.0"
Version = "0.5.1"

defaultMaxAllowedPacket = 4194304
)
Expand Down Expand Up @@ -302,7 +301,7 @@ func (table *table) CreateSQL() (string, error) {
}

func (table *table) Init() (err error) {
if len(table.types) != 0 {
if len(table.values) != 0 {
return errors.New("can't init twice")
}

Expand All @@ -324,22 +323,22 @@ func (table *table) Init() (err error) {
return err
}

table.types = make([]reflect.Type, len(tt))
var t reflect.Type
table.values = make([]interface{}, len(tt))
for i, tp := range tt {
st := tp.ScanType()
if tp.DatabaseTypeName() == "BLOB" {
table.types[i] = reflect.TypeOf(sql.RawBytes{})
t = reflect.TypeOf(sql.RawBytes{})
} else if st != nil && (st.Kind() == reflect.Int ||
st.Kind() == reflect.Int8 ||
st.Kind() == reflect.Int16 ||
st.Kind() == reflect.Int32 ||
st.Kind() == reflect.Int64) {
table.types[i] = reflect.TypeOf(sql.NullInt64{})
t = reflect.TypeOf(sql.NullInt64{})
} else {
table.types[i] = reflect.TypeOf(sql.NullString{})
t = reflect.TypeOf(sql.NullString{})
}
table.values[i] = reflect.New(table.types[i]).Interface()
table.values[i] = reflect.New(t).Interface()
}
return nil
}
Expand Down

0 comments on commit 38ef509

Please sign in to comment.