Skip to content

Commit

Permalink
修复使用paginator时,limit未清除导致复合Count功能不正确
Browse files Browse the repository at this point in the history
  • Loading branch information
tobycroft committed Oct 13, 2022
1 parent 08d6cc9 commit 57a2f93
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion orm_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (dba *Orm) Counts(count_fileds ...string) (int64, error) {
if dba.group == "" {
return dba.Count(count_fileds...)
} else {
dba.limit = 0
dba.fields = []string{"count(DISTINCT " + dba.group + ") as count"}
// 构建sql
sqls, args, err := dba.BuildSql()
Expand All @@ -84,6 +85,7 @@ func (dba *Orm) Counts(count_fileds ...string) (int64, error) {
if err != nil {
return 0, err
}
//fmt.Println(dba.LastSql())
if len(total_number) < 1 {
return 0, err
}
Expand Down Expand Up @@ -533,7 +535,6 @@ func (dba *Orm) Paginator(page ...int) (res Paginate, err error) {
dba.GetISession().GetIBinder().SetBindName(tabname)
dba.GetISession().GetIBinder().SetBindPrefix(prefix)
dba.where = where

count, err2 := dba.Counts()
if err2 != nil {
err = err2
Expand Down

0 comments on commit 57a2f93

Please sign in to comment.