Fix scope Fields with embedded struct

This commit is contained in:
Jinzhu 2015-02-25 11:17:33 +08:00
parent 07af30c548
commit 087b7083ad
2 changed files with 7 additions and 1 deletions

View File

@ -39,4 +39,10 @@ func TestSaveAndQueryEmbeddedStruct(t *testing.T) {
if DB.NewScope(&HNPost{}).PrimaryKeyField() == nil {
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")
}
}
}

View File

@ -237,7 +237,7 @@ func (scope *Scope) GetModelStruct(noRelationship ...bool) *ModelStruct {
modelStruct.PrimaryKeyField = f
}
}
break
continue
} else {
belongsToForeignKey := foreignKey
if belongsToForeignKey == "" {