forked from mirror/gorm
Fix overwrite Statement in scopes
This commit is contained in:
parent
a855fe6402
commit
82cb4ebfe2
16
callbacks.go
16
callbacks.go
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue