Skip to content

Commit

Permalink
add todo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Jan 17, 2020
1 parent f7529ab commit 883bb91
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions GoMybatisRowsDecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ func rows2maps(rows *sql.Rows) (resultsSlice []map[string][]byte, err error) {
if err != nil {
return nil, err
}
fieldTypes, err := rows.ColumnTypes()
if err != nil {
return nil, err
}
for rows.Next() {
result, err := row2map(rows, fields)
result, err := row2map(rows, fields, fieldTypes)
if err != nil {
return nil, err
}
Expand All @@ -23,7 +27,7 @@ func rows2maps(rows *sql.Rows) (resultsSlice []map[string][]byte, err error) {
return resultsSlice, nil
}

func row2map(rows *sql.Rows, fields []string) (resultsMap map[string][]byte, err error) {
func row2map(rows *sql.Rows, fields []string, fieldTypes []*sql.ColumnType) (resultsMap map[string][]byte, err error) {
result := make(map[string][]byte)
scanResultContainers := make([]interface{}, len(fields))
for i := 0; i < len(fields); i++ {
Expand All @@ -42,15 +46,16 @@ func row2map(rows *sql.Rows, fields []string) (resultsMap map[string][]byte, err
continue
}

if data, err := value2Bytes(&rawValue, key); err == nil {
if data, err := value2Bytes(&rawValue, key, fieldTypes[ii]); err == nil {
result[key] = data
} else {
return nil, err // !nashtsai! REVIEW, should return err or just error log?
}
}
return result, nil
}
func value2Bytes(rawValue *reflect.Value, column string) ([]byte, error) {

func value2Bytes(rawValue *reflect.Value, column string, columnType *sql.ColumnType) ([]byte, error) {
//TODO convert type with column and column type
str, err := value2String(rawValue)
if err != nil {
Expand Down

0 comments on commit 883bb91

Please sign in to comment.