fixed issue 1246 with a nested select

This commit is contained in:
mdipierro
2013-04-06 09:38:16 -05:00
parent 6eea834777
commit 4a078705b3
2 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.5-stable+timestamp.2013.04.05.15.59.29
Version 2.4.5-stable+timestamp.2013.04.06.09.37.36
+9 -7
View File
@@ -2121,13 +2121,15 @@ class SQLFORM(FORM):
if subquery:
dbset = dbset(subquery)
try:
if left or groupby:
if groupby:
c = 'count(distinct %s)' % str(groupby)
else:
c = 'count(*)'
nrows = dbset.select(c, left=left, cacheable=True,
groupby=groupby).first()[c]
if groupby:
c = 'count(*)'
nrows = db.executesql(
'select count(*) from (%s);' %
dbset._select(c, left=left, cacheable=True,
groupby=groupby)[:-1])[0][0]
elif left:
c = 'count(*)'
nrows = dbset.select(c, left=left, cacheable=True).first()[c]
elif dbset._db._adapter.dbengine=='google:datastore':
#if we don't set a limit, this can timeout for a large table
nrows = dbset.db._adapter.count(dbset.query, limit=1000)