forked from mirror/gorm
Only load Fields when defined preload
This commit is contained in:
parent
e3d70302f3
commit
0e2cd4475f
|
@ -20,10 +20,10 @@ func equalAsString(a interface{}, b interface{}) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Preload(scope *Scope) {
|
func Preload(scope *Scope) {
|
||||||
|
if scope.Search.preload != nil {
|
||||||
fields := scope.Fields()
|
fields := scope.Fields()
|
||||||
isSlice := scope.IndirectValue().Kind() == reflect.Slice
|
isSlice := scope.IndirectValue().Kind() == reflect.Slice
|
||||||
|
|
||||||
if scope.Search.preload != nil {
|
|
||||||
for key, conditions := range scope.Search.preload {
|
for key, conditions := range scope.Search.preload {
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
if field.Name == key && field.Relationship != nil {
|
if field.Name == key && field.Relationship != nil {
|
||||||
|
|
Loading…
Reference in New Issue