Skip to content

Commit ab988b0

Browse files
committed
1. Fixed TODO
1 parent 2fdd8e6 commit ab988b0

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

gorm/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Implementation rewrites [DisableNestedTransaction](https://gorm.io/docs/gorm_config.html#DisableNestedTransaction) by [Settings.Propogation](../trm/settings.go) if it is [PropagationNested](../trm/transaction.go).
2+

gorm/factory.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func NewDefaultFactory(db *gorm.DB) trm.TrFactory {
1616
return func(ctx context.Context, trms trm.Settings) (context.Context, trm.Transaction, error) {
1717
s, _ := trms.(Settings)
1818

19-
// TODO do update TRM config by settings gorm nested transaction
20-
// db.DisableNestedTransaction = true
19+
db.Config.DisableNestedTransaction = trms.Propagation() != trm.PropagationNested
2120

2221
return NewTransaction(ctx, s.TxOpts(), db)
2322
}

redis/settings.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ func (s *Settings) Return() []redis.Cmder {
160160

161161
// AppendReturn append []redis.Cmder from Transaction.
162162
func (s *Settings) AppendReturn(cmds ...redis.Cmder) {
163+
if s.ReturnPtr() == nil {
164+
return
165+
}
166+
163167
s.muRet.Lock()
164168
defer s.muRet.Unlock()
165169

redis/transaction.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewTransaction(
6060
return t.isClosedClosure.Err()
6161
})
6262

63-
if len(cmds) > 0 && s.ReturnPtr() != nil {
63+
if len(cmds) > 0 {
6464
s.AppendReturn(cmds...)
6565
}
6666

@@ -108,10 +108,7 @@ func (t *Transaction) Transaction() interface{} {
108108
func (t *Transaction) Commit(ctx context.Context) error {
109109
select {
110110
case <-t.isClosed.Closed():
111-
cmds, err := t.tx.Exec(ctx)
112-
113-
// TODO process cmds
114-
_ = cmds
111+
_, err := t.tx.Exec(ctx)
115112

116113
return err
117114
default:

0 commit comments

Comments
 (0)