Hey guys,
Is there a reason why Field.count() now returns an Expression of type=self.type instead of 'integer'? It breaks code that uses datetime columns with count and groupby, like so:
db().select(db.tablename.addedTime, db.tablename.addedTime.count(), groupby=db.tablename.addedTime.month() | db.tablename.addedTime.year()).first()
(Gives a ValueError: need more than 1 value to unpack because, since the Expression is a 'datetime', it calls parse_datetime with an integer value.)
The patch is simple:
(Line 8311, latest version of trunk)
- return Expression(self.db, self.db._adapter.COUNT, self, distinct, self.type)
+ return Expression(self.db, self.db._adapter.COUNT, self, distinct, 'integer')
Doesn't seem to be a reason why it was switched from self.type to integer.