Lazy call registered scopes

This commit is contained in:
Jinzhu 2021-02-25 22:01:59 +08:00
parent 6b7d18656d
commit ddeb143eb9
1 changed files with 3 additions and 2 deletions

View File

@ -482,8 +482,9 @@ func (stmt *Statement) clone() *Statement {
copy(newStmt.Joins, stmt.Joins) copy(newStmt.Joins, stmt.Joins)
} }
for _, scope := range stmt.scopes { if len(stmt.scopes) > 0 {
stmt.scopes = append(stmt.scopes, scope) newStmt.scopes = make([]func(*DB) *DB, len(stmt.scopes))
copy(newStmt.scopes, stmt.scopes)
} }
stmt.Settings.Range(func(k, v interface{}) bool { stmt.Settings.Range(func(k, v interface{}) bool {