From c041e5361273f7223637a114f9f797051b6a96f4 Mon Sep 17 00:00:00 2001 From: deoxxa Date: Tue, 28 Oct 2014 11:29:33 +1100 Subject: [PATCH] fix query generation for one-to-one relations --- scope_private.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scope_private.go b/scope_private.go index 85c5462a..2b66de8b 100644 --- a/scope_private.go +++ b/scope_private.go @@ -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 } }