Skip to content

Commit

Permalink
1. Fixed TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
maranqz committed Feb 4, 2024
1 parent 2fdd8e6 commit 19a2bed
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions gorm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Implementation rewrites [DisableNestedTransaction](https://gorm.io/docs/gorm_config.html#DisableNestedTransaction) by [Settings.Propogation](../trm/settings.go) if it is [PropagationNested](../trm/transaction.go).

3 changes: 1 addition & 2 deletions gorm/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ func NewDefaultFactory(db *gorm.DB) trm.TrFactory {
return func(ctx context.Context, trms trm.Settings) (context.Context, trm.Transaction, error) {
s, _ := trms.(Settings)

// TODO do update TRM config by settings gorm nested transaction
// db.DisableNestedTransaction = true
db.DisableNestedTransaction = s.Propagation() == trm.PropagationNested

return NewTransaction(ctx, s.TxOpts(), db)
}
Expand Down
4 changes: 4 additions & 0 deletions redis/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func (s *Settings) Return() []redis.Cmder {

// AppendReturn append []redis.Cmder from Transaction.
func (s *Settings) AppendReturn(cmds ...redis.Cmder) {
if s.ReturnPtr() == nil {
return
}

s.muRet.Lock()
defer s.muRet.Unlock()

Expand Down
7 changes: 2 additions & 5 deletions redis/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewTransaction(
return t.isClosedClosure.Err()
})

if len(cmds) > 0 && s.ReturnPtr() != nil {
if len(cmds) > 0 {
s.AppendReturn(cmds...)
}

Expand Down Expand Up @@ -108,10 +108,7 @@ func (t *Transaction) Transaction() interface{} {
func (t *Transaction) Commit(ctx context.Context) error {
select {
case <-t.isClosed.Closed():
cmds, err := t.tx.Exec(ctx)

// TODO process cmds
_ = cmds
_, err := t.tx.Exec(ctx)

return err
default:
Expand Down

0 comments on commit 19a2bed

Please sign in to comment.