r.db.RunInTransaction can not use r.db.ModelContext
chacoChao opened this issue · 0 comments
chacoChao commented
Issue tracker is used for reporting bugs and discussing new features. Please use
Discord or stackoverflow for supporting
issues.
Expected Behavior
r.db.RunInTransaction can not use r.db.ModelContext
`
r.db.RunInTransaction(ctx, func(tx *pg.Tx) error {
_, err := tx.ModelContext(ctx, (*xxx)(nil)).WherePK("id = ?", xId).Delete()
_, err = tx.ModelContext(ctx, (*yyy)(nil)).Where("id = ?", yId)Delete()
// err="context canceled". the resason is can not get conn from db.pool
//_, err = r.db.ModelContext(ctx, (*yyy)(nil)).WherePK("id = ?", clientId).Delete()
`
Current Behavior
db.Model(book).Where().Delete()
if table no rows. do delete() err = "context canceled"
Possible Solution
add condition rows empty return replace err