From 506f85d741ad68f0bf8786044ca4e3f18fb895c4 Mon Sep 17 00:00:00 2001 From: Steve Fan <29133953+stevefan1999-personal@users.noreply.github.com> Date: Sat, 29 Aug 2020 19:05:04 +0800 Subject: [PATCH] remove Workarounds.*, add DoColumnLowerCasingOnSchemaScanning --- go.sum | 13 +++++++++++++ gorm.go | 6 ++---- scan.go | 6 ++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/go.sum b/go.sum index 148bd6f5..7e3990ac 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,17 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/thoas/go-funk v0.7.0 h1:GmirKrs6j6zJbhJIficOsz2aAI7700KsU/5YrdHRM1Y= +github.com/thoas/go-funk v0.7.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/gorm.go b/gorm.go index f9e54bf8..6e304bc1 100644 --- a/gorm.go +++ b/gorm.go @@ -32,12 +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 - } // AllowGlobalUpdate allow global update AllowGlobalUpdate bool + // DoColumnLowerCasingOnSchemaParsing turn all the column names returned from a result set to lower case for some weird database + DoColumnLowerCasingOnSchemaParsing bool // ClauseBuilders clause builder ClauseBuilders map[string]clause.ClauseBuilder diff --git a/scan.go b/scan.go index d3e158e7..b77c16ee 100644 --- a/scan.go +++ b/scan.go @@ -14,10 +14,8 @@ func Scan(rows *sql.Rows, db *DB, initialized bool) { columns, _ := rows.Columns() values := make([]interface{}, len(columns)) - if db.Workarounds.DoColumnLowerCasing { - columns = funk.Map(columns, func(s string) string { - return strings.ToLower(s) - }).([]string) + if db.DoColumnLowerCasingOnSchemaParsing { + columns = funk.Map(columns, strings.ToLower).([]string) } switch dest := db.Statement.Dest.(type) {