From 198fc47051ff189b046a9bf8acee1964c23b9fc4 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 25 Sep 2015 17:14:21 +0800 Subject: [PATCH] Include all primary fields when build where conditions --- scope_private.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scope_private.go b/scope_private.go index f47c8433..5b04a639 100644 --- a/scope_private.go +++ b/scope_private.go @@ -164,7 +164,10 @@ func (scope *Scope) whereSql() (sql string) { } if !scope.PrimaryKeyZero() { - primaryConditions = append(primaryConditions, scope.primaryCondition(scope.AddToVars(scope.PrimaryKeyValue()))) + for _, field := range scope.PrimaryFields() { + sql := fmt.Sprintf("(%v = %v)", scope.Quote(field.DBName), scope.AddToVars(field.Field.Interface())) + primaryConditions = append(primaryConditions, sql) + } } for _, clause := range scope.Search.whereConditions {