mirror of https://github.com/go-gorm/gorm.git
Fix delete order by clause when counting, close #4478
This commit is contained in:
parent
52b72d7ef2
commit
83530ec659
|
@ -376,7 +376,7 @@ func (db *DB) Count(count *int64) (tx *DB) {
|
||||||
|
|
||||||
if selectClause, ok := db.Statement.Clauses["SELECT"]; ok {
|
if selectClause, ok := db.Statement.Clauses["SELECT"]; ok {
|
||||||
defer func() {
|
defer func() {
|
||||||
db.Statement.Clauses["SELECT"] = selectClause
|
tx.Statement.Clauses["SELECT"] = selectClause
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
defer delete(tx.Statement.Clauses, "SELECT")
|
defer delete(tx.Statement.Clauses, "SELECT")
|
||||||
|
@ -410,9 +410,9 @@ func (db *DB) Count(count *int64) (tx *DB) {
|
||||||
|
|
||||||
if orderByClause, ok := db.Statement.Clauses["ORDER BY"]; ok {
|
if orderByClause, ok := db.Statement.Clauses["ORDER BY"]; ok {
|
||||||
if _, ok := db.Statement.Clauses["GROUP BY"]; !ok {
|
if _, ok := db.Statement.Clauses["GROUP BY"]; !ok {
|
||||||
delete(db.Statement.Clauses, "ORDER BY")
|
delete(tx.Statement.Clauses, "ORDER BY")
|
||||||
defer func() {
|
defer func() {
|
||||||
db.Statement.Clauses["ORDER BY"] = orderByClause
|
tx.Statement.Clauses["ORDER BY"] = orderByClause
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue