forked from mirror/gorm
HasColumn with ignored column
This commit is contained in:
parent
726b3b8c9f
commit
2069364296
7
scope.go
7
scope.go
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue