From 0f0a62ef7fb392bcceedafb6563c80ffe396bb37 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Thu, 4 Apr 2013 21:11:19 -0500 Subject: [PATCH] possible fix for Issue 1426:Count(*) query is incorrect when SQLFORM.grid() contains groupby parameter, thanks daveshih01 --- VERSION | 2 +- gluon/sqlhtml.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 7245720d..d9beb281 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.5-stable+timestamp.2013.04.03.16.48.32 +Version 2.4.5-stable+timestamp.2013.04.04.21.10.38 diff --git a/gluon/sqlhtml.py b/gluon/sqlhtml.py index b110b5d8..fac59c5a 100644 --- a/gluon/sqlhtml.py +++ b/gluon/sqlhtml.py @@ -2122,7 +2122,10 @@ class SQLFORM(FORM): dbset = dbset(subquery) try: if left or groupby: - c = 'count(*)' + if groupby: + c = 'count(distinct %s)' % str(groupby) + else: + c = 'count(*)' nrows = dbset.select(c, left=left, cacheable=True, groupby=groupby).first()[c] elif dbset._db._adapter.dbengine=='google:datastore':