Fix overwrite Statement in scopes

This commit is contained in:
Jinzhu 2021-04-22 13:12:15 +08:00
parent a855fe6402
commit 82cb4ebfe2
1 changed files with 8 additions and 8 deletions

View File

@ -72,20 +72,20 @@ func (cs *callbacks) Raw() *processor {
} }
func (p *processor) Execute(db *DB) { func (p *processor) Execute(db *DB) {
var (
curTime = time.Now()
stmt = db.Statement
)
// call scopes // call scopes
for len(stmt.scopes) > 0 { for len(db.Statement.scopes) > 0 {
scopes := stmt.scopes scopes := db.Statement.scopes
stmt.scopes = nil db.Statement.scopes = nil
for _, scope := range scopes { for _, scope := range scopes {
db = scope(db) db = scope(db)
} }
} }
var (
curTime = time.Now()
stmt = db.Statement
)
// assign model values // assign model values
if stmt.Model == nil { if stmt.Model == nil {
stmt.Model = stmt.Dest stmt.Model = stmt.Dest