workaround some shitty db that returns capitalized letter for column name
This commit is contained in:
parent
ef002fd7ac
commit
13cd287a6f
1
go.mod
1
go.mod
@ -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
|
||||
)
|
||||
|
6
scan.go
6
scan.go
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user