From bf545ef24ab9bb546ef3ad2c15ad3e6be5c96a74 Mon Sep 17 00:00:00 2001 From: qqxhb <1252905006@qq.com> Date: Mon, 23 Sep 2024 11:47:06 +0800 Subject: [PATCH] fix: Updates method is invalid for tag type hooks --- do.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/do.go b/do.go index aca161a5..72dfd178 100644 --- a/do.go +++ b/do.go @@ -77,7 +77,7 @@ func (d *DO) ReplaceConnPool(pool gorm.ConnPool) { // UseModel specify a data model structure as a source for table name func (d *DO) UseModel(model interface{}) { d.modelType = d.indirect(model) - + d.db = d.db.Model(model).Session(&gorm.Session{}) err := d.db.Statement.Parse(model) if err != nil { panic(fmt.Errorf("Cannot parse model: %+v\n%w", model, err)) @@ -710,7 +710,7 @@ func (d *DO) Updates(value interface{}) (info ResultInfo, err error) { valTyp = rawTyp } - tx := d.db + tx := d.db.Model(d.newResultPointer()) if d.backfillData != nil { tx = tx.Model(d.backfillData) }