diff --git a/VERSION b/VERSION index 5361b1ce..3ede469c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-07-12 15:31:21) dev +Version 2.00.0 (2012-07-13 18:04:08) dev diff --git a/gluon/dal.py b/gluon/dal.py index 92aff5cd..80fb2d4d 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -958,6 +958,9 @@ class BaseAdapter(ConnectionPool): def UPPER(self, first): return 'UPPER(%s)' % self.expand(first) + def COUNT(self, first, distinct=None): + return 'COUNT()' if not distinct else 'COUNT(DISTINCT %s)' % self.expand(first) + def EXTRACT(self, first, what): return "EXTRACT(%s FROM %s)" % (what, self.expand(first)) @@ -8174,8 +8177,8 @@ class Field(Expression): return (value, error) return (value, None) - def count(self): - return Expression(self.db, self.db._adapter.AGGREGATE, self, 'COUNT', 'integer') + def count(self, expression=None): + return Expression(self.db, self.db._adapter.COUNT, self, expression, self.type) def __nonzero__(self): return True