Skip to content

Commit d7de699

Browse files
authored
Merge pull request #1217 from go-gorm/fix_updates_tag_hook
fix: Updates method is invalid for tag type hooks
2 parents ebb6364 + bf545ef commit d7de699

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

do.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (d *DO) ReplaceConnPool(pool gorm.ConnPool) {
7777
// UseModel specify a data model structure as a source for table name
7878
func (d *DO) UseModel(model interface{}) {
7979
d.modelType = d.indirect(model)
80-
80+
d.db = d.db.Model(model).Session(&gorm.Session{})
8181
err := d.db.Statement.Parse(model)
8282
if err != nil {
8383
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) {
710710
valTyp = rawTyp
711711
}
712712

713-
tx := d.db
713+
tx := d.db.Model(d.newResultPointer())
714714
if d.backfillData != nil {
715715
tx = tx.Model(d.backfillData)
716716
}

0 commit comments

Comments
 (0)