Include model value when preloading many2many relations to enable row query callbacks

This commit is contained in:
Jinzhu 2016-06-17 18:18:46 +08:00
parent 18917d1f3e
commit caa792644c
1 changed files with 1 additions and 1 deletions

View File

@ -262,7 +262,7 @@ func (scope *Scope) handleManyToManyPreload(field *Field, conditions []interface
// generate query with join table // generate query with join table
newScope := scope.New(reflect.New(fieldType).Interface()) 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) preloadDB = joinTableHandler.JoinWith(joinTableHandler, preloadDB, scope.Value)
// preload inline conditions // preload inline conditions