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.Tag = fieldStruct.Tag
|
||||||
field.SqlTag = scope.sqlTagForField(&field)
|
field.SqlTag = scope.sqlTagForField(&field)
|
||||||
|
|
||||||
|
if !field.IsIgnored {
|
||||||
// parse association
|
// parse association
|
||||||
typ := indirectValue.Type()
|
typ := indirectValue.Type()
|
||||||
foreignKey := SnakeToUpperCamel(settings["FOREIGNKEY"])
|
foreignKey := SnakeToUpperCamel(settings["FOREIGNKEY"])
|
||||||
|
@ -318,6 +319,7 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) *Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return &field
|
return &field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,6 +308,7 @@ func (scope *Scope) sqlTagForField(field *Field) (typ string) {
|
||||||
fieldTag := field.Tag.Get(scope.db.parent.tagIdentifier)
|
fieldTag := field.Tag.Get(scope.db.parent.tagIdentifier)
|
||||||
if fieldTag == "-" {
|
if fieldTag == "-" {
|
||||||
field.IsIgnored = true
|
field.IsIgnored = true
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var setting = parseTagSetting(fieldTag)
|
var setting = parseTagSetting(fieldTag)
|
||||||
|
|
|
@ -86,6 +86,7 @@ type Product struct {
|
||||||
type Company struct {
|
type Company struct {
|
||||||
Id int64
|
Id int64
|
||||||
Name string
|
Name string
|
||||||
|
Owner *User `sql:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Role struct {
|
type Role struct {
|
||||||
|
|
Loading…
Reference in New Issue