go-pg/pg

r.db.RunInTransaction can not use r.db.ModelContext

chacoChao opened this issue · 0 comments

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"
image

image

image

Possible Solution

add condition rows empty return replace err

Steps to Reproduce

Context (Environment)

Detailed Description

Possible Implementation