Skip to content

Commit

Permalink
handle slice of bytes for mysql values
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Starostenko committed Jul 23, 2020
1 parent a1c9388 commit 8da27b7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@ func getRows(rows *sql.Rows, nulls bool, max int) ([]map[string]interface{}, boo

obj := make(map[string]interface{})
for i, col := range columns {
if nulls || values[i] != nil {
obj[col] = values[i]
val := values[i]
if nulls || val != nil {
var v interface{}
b, ok := val.([]byte)
if ok {
v = string(b)
} else {
v = val
}
obj[col] = v
}
}
result = append(result, obj)
result = append(result, obj)

max--
}
Expand All @@ -45,4 +53,4 @@ func getRows(rows *sql.Rows, nulls bool, max int) ([]map[string]interface{}, boo
func getAllRows(rows *sql.Rows, null bool) ([]map[string]interface{}, error) {
data, _, err := getRows(rows, null, -1)
return data, err
}
}

0 comments on commit 8da27b7

Please sign in to comment.