Merge 24679618ad442e36f0b5104d1dc2cb68d5f91007 into 8e7ab46c1b865386bbb8f5322d64880ee5ce6f40
This commit is contained in:
commit
862624b1b2
@ -86,6 +86,10 @@ func Create(config *Config) func(db *gorm.DB) {
|
|||||||
)
|
)
|
||||||
if db.AddError(err) == nil {
|
if db.AddError(err) == nil {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
// Make sure it's processed and errors are taken into account.
|
||||||
|
if !rows.Next() {
|
||||||
|
db.AddError(rows.Err())
|
||||||
|
}
|
||||||
db.AddError(rows.Close())
|
db.AddError(rows.Close())
|
||||||
}()
|
}()
|
||||||
gorm.Scan(rows, db, mode)
|
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 {
|
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)
|
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())
|
db.AddError(rows.Close())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,10 @@ func Query(db *gorm.DB) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
// Make sure it's processed and errors are taken into account.
|
||||||
|
if !rows.Next() {
|
||||||
|
db.AddError(rows.Err())
|
||||||
|
}
|
||||||
db.AddError(rows.Close())
|
db.AddError(rows.Close())
|
||||||
}()
|
}()
|
||||||
gorm.Scan(rows, db, 0)
|
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()
|
db.Statement.Dest = db.Statement.ReflectValue.Addr().Interface()
|
||||||
gorm.Scan(rows, db, mode)
|
gorm.Scan(rows, db, mode)
|
||||||
db.Statement.Dest = dest
|
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())
|
db.AddError(rows.Close())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
4
scan.go
4
scan.go
@ -350,10 +350,6 @@ func Scan(rows Rows, db *DB, mode ScanMode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := rows.Err(); err != nil && err != db.Error {
|
|
||||||
db.AddError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if db.RowsAffected == 0 && db.Statement.RaiseErrorOnNotFound && db.Error == nil {
|
if db.RowsAffected == 0 && db.Statement.RaiseErrorOnNotFound && db.Error == nil {
|
||||||
db.AddError(ErrRecordNotFound)
|
db.AddError(ErrRecordNotFound)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user