mirror of https://github.com/go-gorm/gorm.git
Fix scope Fields with embedded struct
This commit is contained in:
parent
07af30c548
commit
087b7083ad
|
@ -39,4 +39,10 @@ func TestSaveAndQueryEmbeddedStruct(t *testing.T) {
|
||||||
if DB.NewScope(&HNPost{}).PrimaryKeyField() == nil {
|
if DB.NewScope(&HNPost{}).PrimaryKeyField() == nil {
|
||||||
t.Errorf("primary key with embedded struct should works")
|
t.Errorf("primary key with embedded struct should works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, field := range DB.NewScope(&HNPost{}).Fields() {
|
||||||
|
if field.Name == "BasePost" {
|
||||||
|
t.Errorf("scope Fields should not contain embedded struct")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ func (scope *Scope) GetModelStruct(noRelationship ...bool) *ModelStruct {
|
||||||
modelStruct.PrimaryKeyField = f
|
modelStruct.PrimaryKeyField = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
continue
|
||||||
} else {
|
} else {
|
||||||
belongsToForeignKey := foreignKey
|
belongsToForeignKey := foreignKey
|
||||||
if belongsToForeignKey == "" {
|
if belongsToForeignKey == "" {
|
||||||
|
|
Loading…
Reference in New Issue