Fix RowsAffected tests

This commit is contained in:
Jinzhu 2014-06-09 08:17:20 +08:00
parent 5f0e640f3d
commit bab148f90c
2 changed files with 4 additions and 2 deletions

View File

@ -60,7 +60,9 @@ func Create(scope *Scope) {
}
}
} else {
scope.Err(scope.DB().QueryRow(scope.Sql, scope.SqlVars...).Scan(&id))
if scope.Err(scope.DB().QueryRow(scope.Sql, scope.SqlVars...).Scan(&id)) == nil {
scope.db.RowsAffected = 1
}
}
if !scope.HasError() {

View File

@ -1111,7 +1111,7 @@ func TestUpdate(t *testing.T) {
var animals []Animal
db.Find(&animals)
if count := db.Model(Animal{}).Update("CreatedAt", time.Now()).RowsAffected; count != int64(len(animals)) {
if count := db.Model(Animal{}).Update("CreatedAt", time.Now().Add(2*time.Hour)).RowsAffected; count != int64(len(animals)) {
t.Error("RowsAffected should be correct when do batch update")
}
}