Include all primary fields when build where conditions

This commit is contained in:
Jinzhu 2015-09-25 17:14:21 +08:00
parent 19aacb8fbb
commit 198fc47051
1 changed files with 4 additions and 1 deletions

View File

@ -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 {