From 9cf24c38810d03ad70e1aa88fb4897e03246424f Mon Sep 17 00:00:00 2001 From: qqxhb <1252905006@qq.com> Date: Wed, 4 Jan 2023 17:26:51 +0800 Subject: [PATCH] fix: replace db --- do.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/do.go b/do.go index 4310abe0..adfdd656 100644 --- a/do.go +++ b/do.go @@ -64,7 +64,9 @@ func (d *DO) UseDB(db *gorm.DB, opts ...DOOption) { } // ReplaceDB replace db connection -func (d *DO) ReplaceDB(db *gorm.DB) { d.db = db } +func (d *DO) ReplaceDB(db *gorm.DB) { + d.db = db.Session(&gorm.Session{}) +} // ReplaceConnPool replace db connection pool func (d *DO) ReplaceConnPool(pool gorm.ConnPool) {