          field_cast_sql = backend.get_field_cast_sql(db_type)
      else:
          field_cast_sql = '%s%s'
      field_sql = field_cast_sql % (table_prefix, field_name)
      if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and backend.needs_upper_for_iops:
          format = 'UPPER(%s) %s'
      else:
          format = '%s %s'
      try:
          return format % (field_sql, backend.OPERATOR_MAPPING[lookup_type] % cast_sql)
 
</s> remove         if backend.allows_group_by_ordinal:
 </s> add         if connection.features.allows_group_by_ordinal: </s> remove     if backend.uses_case_insensitive_names:
 </s> add     if connection.features.uses_case_insensitive_names: </s> remove             if tablespace and backend.supports_tablespaces:
 </s> add             if tablespace and connection.features.supports_tablespaces:
    if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and connection.features.needs_upper_for_iops:
          field_cast_sql = backend.get_field_cast_sql(db_type)
      else:
          field_cast_sql = '%s%s'
      field_sql = field_cast_sql % (table_prefix, field_name)
    if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith') and connection.features.needs_upper_for_iops:
          format = 'UPPER(%s) %s'
      else:
          format = '%s %s'
      try:
          return format % (field_sql, backend.OPERATOR_MAPPING[lookup_type] % cast_sql)
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