diff options
Diffstat (limited to 'vendor/github.com/go-xorm/xorm/helpers.go')
-rw-r--r-- | vendor/github.com/go-xorm/xorm/helpers.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/vendor/github.com/go-xorm/xorm/helpers.go b/vendor/github.com/go-xorm/xorm/helpers.go index f59db48b1d..7efa729435 100644 --- a/vendor/github.com/go-xorm/xorm/helpers.go +++ b/vendor/github.com/go-xorm/xorm/helpers.go @@ -490,9 +490,8 @@ func genCols(table *core.Table, session *Session, bean interface{}, useCol bool, args := make([]interface{}, 0, len(table.ColumnsSeq())) for _, col := range table.Columns() { - lColName := strings.ToLower(col.Name) if useCol && !col.IsVersion && !col.IsCreated && !col.IsUpdated { - if _, ok := session.Statement.columnMap[lColName]; !ok { + if _, ok := getFlagForColumn(session.Statement.columnMap, col); !ok { continue } } @@ -528,18 +527,18 @@ func genCols(table *core.Table, session *Session, bean interface{}, useCol bool, } if session.Statement.ColumnStr != "" { - if _, ok := session.Statement.columnMap[lColName]; !ok { + if _, ok := getFlagForColumn(session.Statement.columnMap, col); !ok { continue } } if session.Statement.OmitStr != "" { - if _, ok := session.Statement.columnMap[lColName]; ok { + if _, ok := getFlagForColumn(session.Statement.columnMap, col); ok { continue } } // !evalphobia! set fieldValue as nil when column is nullable and zero-value - if _, ok := session.Statement.nullableMap[lColName]; ok { + if _, ok := getFlagForColumn(session.Statement.nullableMap, col); ok { if col.Nullable && isZero(fieldValue.Interface()) { var nilValue *int fieldValue = reflect.ValueOf(nilValue) @@ -578,3 +577,23 @@ func genCols(table *core.Table, session *Session, bean interface{}, useCol bool, func indexName(tableName, idxName string) string { return fmt.Sprintf("IDX_%v_%v", tableName, idxName) } + +func getFlagForColumn(m map[string]bool, col *core.Column) (val bool, has bool) { + + if len(m) == 0 { + return false, false + } + + n := len(col.Name) + + for mk := range m { + if len(mk) != n { + continue + } + if strings.EqualFold(mk, col.Name) { + return m[mk], true + } + } + + return false, false +} |