mirror of https://github.com/go-gorm/gorm.git
Use the same database for Related
This commit is contained in:
parent
0156c26cfa
commit
24d527670b
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue