From 82cb4ebfe2e69c8953536f12e1039807c5643334 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 22 Apr 2021 13:12:15 +0800 Subject: [PATCH] Fix overwrite Statement in scopes --- callbacks.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/callbacks.go b/callbacks.go index ee96fcb9..20fec429 100644 --- a/callbacks.go +++ b/callbacks.go @@ -72,20 +72,20 @@ func (cs *callbacks) Raw() *processor { } func (p *processor) Execute(db *DB) { - var ( - curTime = time.Now() - stmt = db.Statement - ) - // call scopes - for len(stmt.scopes) > 0 { - scopes := stmt.scopes - stmt.scopes = nil + for len(db.Statement.scopes) > 0 { + scopes := db.Statement.scopes + db.Statement.scopes = nil for _, scope := range scopes { db = scope(db) } } + var ( + curTime = time.Now() + stmt = db.Statement + ) + // assign model values if stmt.Model == nil { stmt.Model = stmt.Dest