Only load Fields when defined preload

This commit is contained in:
Jinzhu 2015-04-16 18:39:30 +08:00
parent e3d70302f3
commit 0e2cd4475f
1 changed files with 3 additions and 3 deletions

View File

@ -20,10 +20,10 @@ func equalAsString(a interface{}, b interface{}) bool {
}
func Preload(scope *Scope) {
fields := scope.Fields()
isSlice := scope.IndirectValue().Kind() == reflect.Slice
if scope.Search.preload != nil {
fields := scope.Fields()
isSlice := scope.IndirectValue().Kind() == reflect.Slice
for key, conditions := range scope.Search.preload {
for _, field := range fields {
if field.Name == key && field.Relationship != nil {