Your Question

if I call like this : Gorm panic: query after update (update(XXX).First())

it will panic: Gorm panic: query after update

when I debug code: error will return in here: Gorm panic: query after update Gorm panic: query after update

stmt.Schema continue nil

it's ok so far

but here: Gorm panic: query after update

i think it will come in this if, call db.AddError(xxxx), but it not

so it wil panic at here: Gorm panic: query after update (db.Statement.Schema is nil)

it sames like a bug?

if I call llike this : Gorm panic: query after update

it will achieve my purpose , get the real data after update

gorm version is : gorm.io/gorm v1.22.3

The document you expected this should be explained

Expected answer

I think do not hang up under any circumstances

Comment From: li-jin-gou

参考一下这个文档吧 https://gorm.cn/docs/method_chaining.html gorm v2 会复用 statment,造成条件污染,你这个case里面 statement.Model 被污染了.

Comment From: ChinaRedArmy1930

谢谢 ,学习到了