mirror of https://github.com/go-gorm/gorm.git
fix query generation for one-to-one relations
This commit is contained in:
parent
a29ac54e48
commit
c041e53612
|
@ -475,7 +475,8 @@ func (scope *Scope) related(value interface{}, foreignKeys ...string) *Scope {
|
||||||
|
|
||||||
// has one
|
// has one
|
||||||
if foreignValue, err := scope.FieldValueByName(foreignKey); err == nil {
|
if foreignValue, err := scope.FieldValueByName(foreignKey); err == nil {
|
||||||
toScope.inlineCondition(foreignValue).callCallbacks(scope.db.parent.callback.queries)
|
sql := fmt.Sprintf("%v = ?", scope.Quote(ToSnake(toScope.PrimaryKey())))
|
||||||
|
toScope.inlineCondition(sql, foreignValue).callCallbacks(scope.db.parent.callback.queries)
|
||||||
return scope
|
return scope
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue