From caa792644ce60fd7b429e0616afbdbccdf011be2 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 17 Jun 2016 18:18:46 +0800 Subject: [PATCH] Include model value when preloading many2many relations to enable row query callbacks --- callback_query_preload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback_query_preload.go b/callback_query_preload.go index c71ab4c2..d9ec8bdd 100644 --- a/callback_query_preload.go +++ b/callback_query_preload.go @@ -262,7 +262,7 @@ func (scope *Scope) handleManyToManyPreload(field *Field, conditions []interface // generate query with join table newScope := scope.New(reflect.New(fieldType).Interface()) - preloadDB = preloadDB.Table(newScope.TableName()).Select("*") + preloadDB = preloadDB.Table(newScope.TableName()).Model(newScope.Value).Select("*") preloadDB = joinTableHandler.JoinWith(joinTableHandler, preloadDB, scope.Value) // preload inline conditions