From 20693642965d982c7dbe272f292b9f5186484545 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 19 Jan 2015 16:23:33 +0800 Subject: [PATCH] HasColumn with ignored column --- scope.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scope.go b/scope.go index c53edfc0..f1c7e3ce 100644 --- a/scope.go +++ b/scope.go @@ -140,7 +140,7 @@ func (scope *Scope) PrimaryKeyValue() interface{} { } // HasColumn to check if has column -func (scope *Scope) HasColumn(column string) (hasColumn bool) { +func (scope *Scope) HasColumn(column string) bool { clone := scope if scope.IndirectValue().Kind() == reflect.Slice { value := reflect.New(scope.IndirectValue().Type().Elem()).Interface() @@ -149,9 +149,8 @@ func (scope *Scope) HasColumn(column string) (hasColumn bool) { dbName := ToSnake(column) - _, hasColumn = clone.Fields(false)[dbName] - - return + field, hasColumn := clone.Fields(false)[dbName] + return hasColumn && !field.IsIgnored } // FieldValueByName to get column's value and existence