From 0e2cd4475f53c8143fd5f758933355425dcafdff Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 16 Apr 2015 18:39:30 +0800 Subject: [PATCH] Only load Fields when defined preload --- preload.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/preload.go b/preload.go index d252238a..541f7b95 100644 --- a/preload.go +++ b/preload.go @@ -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 {