  
          table_name = qn(self.model._meta.db_table)
          field_name = qn(self._field.column)
  
          if backend.allows_group_by_ordinal:
              group_by = '1'
          else:
              group_by = connection.ops.date_trunc_sql(self._kind, '%s.%s' % (table_name, field_name))
  
          sql = 'SELECT %s %s GROUP BY %s ORDER BY 1 %s' % \
 
</s> remove     if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and backend.needs_upper_for_iops:
 </s> add     if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and connection.features.needs_upper_for_iops: </s> remove             if tablespace and backend.supports_tablespaces:
 </s> add             if tablespace and connection.features.supports_tablespaces: </s> remove             if tablespace and backend.supports_tablespaces and backend.autoindexes_primary_keys:
 </s> add             if tablespace and connection.features.supports_tablespaces and connection.features.autoindexes_primary_keys: </s> remove     if backend.uses_case_insensitive_names:
 </s> add     if connection.features.uses_case_insensitive_names:
        if connection.features.allows_group_by_ordinal:
  
          table_name = qn(self.model._meta.db_table)
          field_name = qn(self._field.column)
  
        if connection.features.allows_group_by_ordinal:
              group_by = '1'
          else:
              group_by = connection.ops.date_trunc_sql(self._kind, '%s.%s' % (table_name, field_name))
  
          sql = 'SELECT %s %s GROUP BY %s ORDER BY 1 %s' % \
keep keep keep keep replace keep keep keep keep keep
 Implemented BaseDatabaseFeatures and changed all code to access it -- connection.features.foo instead of backend.foo

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5974 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/db/models/query.py