forked from mirror/gorm
Don't panic if can't get address
This commit is contained in:
parent
204356b320
commit
7862dace6b
2
scope.go
2
scope.go
|
@ -342,10 +342,12 @@ func (scope *Scope) fieldFromStruct(fieldStruct reflect.StructField) []*Field {
|
||||||
field.IsNormal = true
|
field.IsNormal = true
|
||||||
} else if embedded := settings["EMBEDDED"]; strings.ToUpper(embedded) == "EMBEDDED" || (embedded == "" && fieldStruct.Anonymous) {
|
} else if embedded := settings["EMBEDDED"]; strings.ToUpper(embedded) == "EMBEDDED" || (embedded == "" && fieldStruct.Anonymous) {
|
||||||
var fields []*Field
|
var fields []*Field
|
||||||
|
if field.Field.CanAddr() {
|
||||||
for _, field := range scope.New(field.Field.Addr().Interface()).Fields() {
|
for _, field := range scope.New(field.Field.Addr().Interface()).Fields() {
|
||||||
field.DBName = field.DBName
|
field.DBName = field.DBName
|
||||||
fields = append(fields, field)
|
fields = append(fields, field)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return fields
|
return fields
|
||||||
} else {
|
} else {
|
||||||
if foreignKey == "" && scope.HasColumn(field.Name+"Id") {
|
if foreignKey == "" && scope.HasColumn(field.Name+"Id") {
|
||||||
|
|
Loading…
Reference in New Issue