forked from mirror/gorm
Fix RowsAffected tests
This commit is contained in:
parent
5f0e640f3d
commit
bab148f90c
|
@ -60,7 +60,9 @@ func Create(scope *Scope) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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() {
|
if !scope.HasError() {
|
||||||
|
|
|
@ -1111,7 +1111,7 @@ func TestUpdate(t *testing.T) {
|
||||||
|
|
||||||
var animals []Animal
|
var animals []Animal
|
||||||
db.Find(&animals)
|
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")
|
t.Error("RowsAffected should be correct when do batch update")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue