From 3be836c72413c8f4c768393d8b83667f4bbccc19 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Mon, 20 Jul 2020 21:26:30 +0800 Subject: [PATCH] make it optional by giving it a workaround field --- gorm.go | 4 ++++ scan.go | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gorm.go b/gorm.go index 338a1473..1671dea3 100644 --- a/gorm.go +++ b/gorm.go @@ -32,6 +32,10 @@ type Config struct { DisableAutomaticPing bool // DisableForeignKeyConstraintWhenMigrating DisableForeignKeyConstraintWhenMigrating bool + // Workarounds this is for some exotic databases that requires internal changes rather than avoiding the problem by extending the dialects + Workarounds struct { + DoColumnLowerCasing bool + } // ClauseBuilders clause builder ClauseBuilders map[string]clause.ClauseBuilder diff --git a/scan.go b/scan.go index 2e5e770e..d3e158e7 100644 --- a/scan.go +++ b/scan.go @@ -14,9 +14,11 @@ 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) + if db.Workarounds.DoColumnLowerCasing { + 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{}: