workaround some shitty db that returns capitalized letter for column name

This commit is contained in:
Steve Fan 2020-07-20 21:09:46 +08:00
parent ef002fd7ac
commit 13cd287a6f
2 changed files with 7 additions and 0 deletions

1
go.mod
View File

@ -5,4 +5,5 @@ go 1.14
require (
github.com/jinzhu/inflection v1.0.0
github.com/jinzhu/now v1.1.1
github.com/thoas/go-funk v0.7.0
)

View File

@ -5,6 +5,8 @@ import (
"reflect"
"strings"
"github.com/thoas/go-funk"
"gorm.io/gorm/schema"
)
@ -12,6 +14,10 @@ func Scan(rows *sql.Rows, db *DB, initialized bool) {
columns, _ := rows.Columns()
values := make([]interface{}, len(columns))
columns = funk.Map(columns, func(s string) string {
return strings.ToLower(s)
}).([]string)
switch dest := db.Statement.Dest.(type) {
case map[string]interface{}, *map[string]interface{}:
if initialized || rows.Next() {