Skip to content

Commit

Permalink
Merge pull request #5 from Hypersequent/avoid-savepoints-for-nested-r…
Browse files Browse the repository at this point in the history
…unintx

Avoid savepoints when calling RunInTx from TxContext
  • Loading branch information
satvik007 authored Aug 6, 2024
2 parents f6d6d4e + dd79407 commit 0d4d77f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions hyperbun.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ func (m TxContext) NewValues(model interface{}) *bun.ValuesQuery {
}

func (m TxContext) RunInTx(fn func(tx TxContext) error) error {
return m.Bun.RunInTx(m.ctx, &sql.TxOptions{}, func(ctx context.Context, tx bun.Tx) error {
return fn(NewTxContext(ctx, tx))
})
return fn(m)
}

func ByID[T any, ID string | int](m DB, id ID) (*T, error) {
Expand Down

0 comments on commit 0d4d77f

Please sign in to comment.