mirror of https://github.com/go-gorm/gorm.git
make Count compatible with Select with Count func, close #3962
This commit is contained in:
parent
4a15540504
commit
3d87575e7e
|
@ -378,7 +378,7 @@ func (db *DB) Count(count *int64) (tx *DB) {
|
|||
|
||||
if len(tx.Statement.Selects) == 0 {
|
||||
tx.Statement.AddClause(clause.Select{Expression: clause.Expr{SQL: "count(1)"}})
|
||||
} else if !strings.Contains(strings.ToLower(tx.Statement.Selects[0]), "count(") {
|
||||
} else if !strings.HasPrefix(strings.TrimSpace(strings.ToLower(tx.Statement.Selects[0])), "count(") {
|
||||
expr := clause.Expr{SQL: "count(1)"}
|
||||
|
||||
if len(tx.Statement.Selects) == 1 {
|
||||
|
|
Loading…
Reference in New Issue