Ticket #19360: 19360_v1.diff

File 19360_v1.diff, 2.3 KB (added by chrismedrela, 11 years ago)
  • django/db/backends/sqlite3/base.py

    diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
    index 6b6c6b6..84b9301 100644
    a b from django.db.backends.signals import connection_created  
    1818from django.db.backends.sqlite3.client import DatabaseClient
    1919from django.db.backends.sqlite3.creation import DatabaseCreation
    2020from django.db.backends.sqlite3.introspection import DatabaseIntrospection
     21from django.db.models import fields
     22from django.db.models.sql import aggregates
    2123from django.utils.dateparse import parse_date, parse_datetime, parse_time
    2224from django.utils.functional import cached_property
    2325from django.utils.safestring import SafeBytes
    class DatabaseOperations(BaseDatabaseOperations):  
    127129        limit = 999 if len(fields) > 1 else 500
    128130        return (limit // len(fields)) if len(fields) > 0 else len(objs)
    129131
     132    def check_aggregate_support(self, aggregate):
     133        # fix for ticket 19360
     134        bad_fields = (fields.DateField, fields.DateTimeField, fields.TimeField)
     135        bad_aggregates = (aggregates.Sum, aggregates.Avg,
     136                          aggregates.Variance, aggregates.StdDev)
     137        if isinstance(aggregate.source, bad_fields) and \
     138           isinstance(aggregate, bad_aggregates):
     139            raise NotImplementedError(
     140                'You cannot use Sum, Avg, StdDev and Variance aggregations '
     141                'on date/time fields in sqlite3 '
     142                'since date/time is saved as text.')
     143
    130144    def date_extract_sql(self, lookup_type, field_name):
    131145        # sqlite doesn't support extract, so we fake it with the user-defined
    132146        # function django_extract that's registered in connect(). Note that
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index 9c2e140..505e5ba 100644
    a b class Query(object):  
    119119        self.filter_is_sticky = False
    120120        self.included_inherited_models = {}
    121121
    122         # SQL-related attributes 
     122        # SQL-related attributes
    123123        # Select and related select clauses as SelectInfo instances.
    124124        # The select is used for cases where we want to set up the select
    125125        # clause to contain other than default fields (values(), annotate(),
Back to Top