7403, a race condition bug fix.
This commit is contained in:
parent
a9d27293de
commit
24679618ad
@ -86,6 +86,10 @@ func Create(config *Config) func(db *gorm.DB) {
|
||||
)
|
||||
if db.AddError(err) == nil {
|
||||
defer func() {
|
||||
// Make sure it's processed and errors are taken into account.
|
||||
if !rows.Next() {
|
||||
db.AddError(rows.Err())
|
||||
}
|
||||
db.AddError(rows.Close())
|
||||
}()
|
||||
gorm.Scan(rows, db, mode)
|
||||
|
@ -166,6 +166,10 @@ func Delete(config *Config) func(db *gorm.DB) {
|
||||
|
||||
if rows, err := db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...); db.AddError(err) == nil {
|
||||
gorm.Scan(rows, db, mode)
|
||||
// Make sure it's processed and errors are taken into account.
|
||||
if !rows.Next() {
|
||||
db.AddError(rows.Err())
|
||||
}
|
||||
db.AddError(rows.Close())
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,10 @@ func Query(db *gorm.DB) {
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
// Make sure it's processed and errors are taken into account.
|
||||
if !rows.Next() {
|
||||
db.AddError(rows.Err())
|
||||
}
|
||||
db.AddError(rows.Close())
|
||||
}()
|
||||
gorm.Scan(rows, db, 0)
|
||||
|
@ -91,6 +91,10 @@ func Update(config *Config) func(db *gorm.DB) {
|
||||
db.Statement.Dest = db.Statement.ReflectValue.Addr().Interface()
|
||||
gorm.Scan(rows, db, mode)
|
||||
db.Statement.Dest = dest
|
||||
// Make sure it's processed and errors are taken into account.
|
||||
if !rows.Next() {
|
||||
db.AddError(rows.Err())
|
||||
}
|
||||
db.AddError(rows.Close())
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user