forked from mirror/gorm
Don't check relations if field is ignored
This commit is contained in:
parent
131b504941
commit
febc826511
2
scope.go
2
scope.go
|
@ -265,6 +265,7 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
|
|||
field.Tag = fieldStruct.Tag
|
||||
field.SqlTag = scope.sqlTagForField(&field)
|
||||
|
||||
if !field.IsIgnored {
|
||||
// parse association
|
||||
typ := indirectValue.Type()
|
||||
foreignKey := SnakeToUpperCamel(settings["FOREIGNKEY"])
|
||||
|
@ -318,6 +319,7 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return &field
|
||||
}
|
||||
|
||||
|
|
|
@ -308,6 +308,7 @@ func (scope *Scope) sqlTagForField(field *Field) (typ string) {
|
|||
fieldTag := field.Tag.Get(scope.db.parent.tagIdentifier)
|
||||
if fieldTag == "-" {
|
||||
field.IsIgnored = true
|
||||
return
|
||||
}
|
||||
|
||||
var setting = parseTagSetting(fieldTag)
|
||||
|
|
|
@ -86,6 +86,7 @@ type Product struct {
|
|||
type Company struct {
|
||||
Id int64
|
||||
Name string
|
||||
Owner *User `sql:"-"`
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
|
|
Loading…
Reference in New Issue