Cleanup Model after Count

This commit is contained in:
Jinzhu 2020-08-19 20:30:39 +08:00
parent 3313c11888
commit 528e5ba5c4
1 changed files with 3 additions and 0 deletions

View File

@ -289,6 +289,9 @@ func (db *DB) Count(count *int64) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if tx.Statement.Model == nil { if tx.Statement.Model == nil {
tx.Statement.Model = tx.Statement.Dest tx.Statement.Model = tx.Statement.Dest
defer func() {
tx.Statement.Model = nil
}()
} }
if len(tx.Statement.Selects) == 0 { if len(tx.Statement.Selects) == 0 {