fix query generation for one-to-one relations

This commit is contained in:
deoxxa 2014-10-28 11:29:33 +11:00
parent a29ac54e48
commit c041e53612
1 changed files with 2 additions and 1 deletions

View File

@ -475,7 +475,8 @@ func (scope *Scope) related(value interface{}, foreignKeys ...string) *Scope {
// has one
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
}
}