We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0be7fa commit 9eb6c60Copy full SHA for 9eb6c60
do.go
@@ -50,7 +50,11 @@ var (
50
51
// UseDB specify a db connection(*gorm.DB)
52
func (d *DO) UseDB(db *gorm.DB, opts ...DOOption) {
53
- db = db.Session(&gorm.Session{Context: context.Background()})
+ ctx := context.Background()
54
+ if db.Statement != nil && db.Statement.Context != nil {
55
+ ctx = db.Statement.Context
56
+ }
57
+ db = db.Session(&gorm.Session{Context: ctx})
58
d.db = db
59
config := &DOConfig{}
60
for _, opt := range opts {
0 commit comments