From 7966cde51410986039fb6707a2ae417ce1bbf869 Mon Sep 17 00:00:00 2001 From: li3p Date: Thu, 16 Apr 2015 14:08:13 +0800 Subject: [PATCH 1/2] look up the Field.Name at Scope.SetColumn --- scope.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scope.go b/scope.go index b83581e2..c42c6afb 100644 --- a/scope.go +++ b/scope.go @@ -158,13 +158,18 @@ func (scope *Scope) HasColumn(column string) bool { func (scope *Scope) SetColumn(column interface{}, value interface{}) error { if field, ok := column.(*Field); ok { return field.Set(value) - } else if dbName, ok := column.(string); ok { + } else if name, ok := column.(string); ok { + + if field, ok := scope.Fields()[name]; ok { + return field.Set(value) + } + + dbName = ToDBName(name) if field, ok := scope.Fields()[dbName]; ok { return field.Set(value) } - dbName = ToDBName(dbName) - if field, ok := scope.Fields()[dbName]; ok { + if field, ok := scope.FieldByName(name); ok { return field.Set(value) } } From f9bd6bcc6418ccd5fcc54862b3b6568747f894a8 Mon Sep 17 00:00:00 2001 From: li3p Date: Thu, 16 Apr 2015 14:28:55 +0800 Subject: [PATCH 2/2] look up the Field.Name at Scope.SetColumn --- scope.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope.go b/scope.go index c42c6afb..f1733aa3 100644 --- a/scope.go +++ b/scope.go @@ -164,7 +164,7 @@ func (scope *Scope) SetColumn(column interface{}, value interface{}) error { return field.Set(value) } - dbName = ToDBName(name) + dbName := ToDBName(name) if field, ok := scope.Fields()[dbName]; ok { return field.Set(value) }