diff --git a/scope_private.go b/scope_private.go index dae943e8..7212af2b 100644 --- a/scope_private.go +++ b/scope_private.go @@ -396,6 +396,7 @@ func (scope *Scope) typeName() string { func (scope *Scope) related(value interface{}, foreignKeys ...string) *Scope { toScope := scope.New(value) + toScope.db = scope.db for _, foreignKey := range append(foreignKeys, toScope.typeName()+"Id", scope.typeName()+"Id") { if foreignValue, ok := scope.FieldByName(foreignKey); ok {