HasColumn with ignored column

This commit is contained in:
Jinzhu 2015-01-19 16:23:33 +08:00
parent 726b3b8c9f
commit 2069364296
1 changed files with 3 additions and 4 deletions

View File

@ -140,7 +140,7 @@ func (scope *Scope) PrimaryKeyValue() interface{} {
} }
// HasColumn to check if has column // HasColumn to check if has column
func (scope *Scope) HasColumn(column string) (hasColumn bool) { func (scope *Scope) HasColumn(column string) bool {
clone := scope clone := scope
if scope.IndirectValue().Kind() == reflect.Slice { if scope.IndirectValue().Kind() == reflect.Slice {
value := reflect.New(scope.IndirectValue().Type().Elem()).Interface() value := reflect.New(scope.IndirectValue().Type().Elem()).Interface()
@ -149,9 +149,8 @@ func (scope *Scope) HasColumn(column string) (hasColumn bool) {
dbName := ToSnake(column) dbName := ToSnake(column)
_, hasColumn = clone.Fields(false)[dbName] field, hasColumn := clone.Fields(false)[dbName]
return hasColumn && !field.IsIgnored
return
} }
// FieldValueByName to get column's value and existence // FieldValueByName to get column's value and existence