db.table.field.count(True), thanks Niphlod

This commit is contained in:
mdipierro
2012-07-13 18:04:13 -05:00
parent 2780f6f032
commit b2c0e1ee1d
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-12 15:31:21) dev
Version 2.00.0 (2012-07-13 18:04:08) dev
+5 -2
View File
@@ -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