Ticket #12471: support_timedelta_aggregate.patch

File support_timedelta_aggregate.patch, 762 bytes (added by Ghislain Leveque, 15 years ago)

This patch add support for the timedelta aggregation

  • query.py

    old new  
    2222from django.db.models.sql.where import WhereNode, Constraint, EverythingNode, AND, OR
    2323from django.core.exceptions import FieldError
    2424
     25import datetime
     26
    2527__all__ = ['Query', 'RawQuery']
    2628
    2729class RawQuery(object):
     
    294296        elif aggregate.is_ordinal:
    295297            # Any ordinal aggregate (e.g., count) returns an int
    296298            return int(value)
     299        elif isinstance(value, datetime.timedelta):
     300            # Value is timedelta, return value as-is
     301            return value
    297302        elif aggregate.is_computed:
    298303            # Any computed aggregate (e.g., avg) returns a float
    299304            return float(value)
Back to Top