Skip to content

Commit 64ff651

Browse files
committed
fix issue in loosing internal ctx data for Transaction for package gdb; fix issue gogf#1732
1 parent d260de1 commit 64ff651

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

database/gdb/gdb_core_transaction.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ func (c *Core) doBeginCtx(ctx context.Context) (*TX, error) {
6969
// Note that, you should not Commit or Rollback the transaction in function `f`
7070
// as it is automatically handled by this function.
7171
func (c *Core) Transaction(ctx context.Context, f func(ctx context.Context, tx *TX) error) (err error) {
72-
var tx *TX
7372
if ctx == nil {
7473
ctx = c.db.GetCtx()
7574
}
75+
ctx = c.InjectInternalCtxData(ctx)
7676
// Check transaction object from context.
77+
var tx *TX
7778
tx = TXFromCtx(ctx, c.db.GetGroup())
7879
if tx != nil {
7980
return tx.Transaction(ctx, f)

database/gdb/gdb_z_mysql_model_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/gogf/gf/v2/database/gdb"
2121
"github.com/gogf/gf/v2/encoding/gjson"
2222
"github.com/gogf/gf/v2/frame/g"
23+
"github.com/gogf/gf/v2/os/gctx"
2324
"github.com/gogf/gf/v2/os/gfile"
2425
"github.com/gogf/gf/v2/os/gtime"
2526
"github.com/gogf/gf/v2/test/gtest"

test/gtest/gtest_util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func AssertNil(value interface{}) {
342342
if err, ok := value.(error); ok {
343343
panic(fmt.Sprintf(`%+v`, err))
344344
}
345-
AssertNE(value, nil)
345+
Assert(value, nil)
346346
}
347347

348348
// DataPath retrieves and returns the testdata path of current package,

0 commit comments

Comments
 (0)