Ticket #5680: autoindex_combined.diff

File autoindex_combined.diff, 6.7 KB (added by Nis Jørgensen <nis@…>, 17 years ago)

Combined with fix for 5671

  • django/db/models/fields/__init__.py

     
    8787        self.name = name
    8888        self.verbose_name = verbose_name
    8989        self.primary_key = primary_key
    90         self.max_length, self.unique = max_length, unique
    91         self.blank, self.null = blank, null
     90        self.max_length = max_length
     91        self.unique = unique or primary_key
     92        self.blank = blank
     93        self.null = null
    9294        # Oracle treats the empty string ('') as null, so coerce the null
    9395        # option whenever '' is a possible value.
    9496        if self.empty_strings_allowed and settings.DATABASE_ENGINE == 'oracle':
     
    98100        self.serialize = serialize
    99101        self.validator_list = validator_list or []
    100102        self.prepopulate_from = prepopulate_from
    101         self.unique_for_date, self.unique_for_month = unique_for_date, unique_for_month
     103        self.unique_for_date = unique_for_date
     104        self.unique_for_month = unique_for_month
    102105        self.unique_for_year = unique_for_year
    103106        self._choices = choices or []
    104107        self.radio_admin = radio_admin
  • django/db/backends/mysql_old/base.py

     
    6464            return getattr(self.cursor, attr)
    6565
    6666class DatabaseFeatures(BaseDatabaseFeatures):
    67     autoindexes_primary_keys = False
     67    pass
    6868
    6969class DatabaseOperations(BaseDatabaseOperations):
    7070    def date_extract_sql(self, lookup_type, field_name):
  • django/db/backends/mysql/base.py

     
    6060# TRADITIONAL will automatically cause most warnings to be treated as errors.
    6161
    6262class DatabaseFeatures(BaseDatabaseFeatures):
    63     autoindexes_primary_keys = False
     63        pass
    6464
    6565class DatabaseOperations(BaseDatabaseOperations):
    6666    def date_extract_sql(self, lookup_type, field_name):
  • django/db/backends/oracle/base.py

     
    2323
    2424class DatabaseFeatures(BaseDatabaseFeatures):
    2525    allows_group_by_ordinal = False
    26     allows_unique_and_pk = False        # Suppress UNIQUE/PK for Oracle (ORA-02259)
    2726    needs_datetime_string_cast = False
    2827    needs_upper_for_iops = True
    2928    supports_tablespaces = True
  • django/db/backends/__init__.py

     
    4141
    4242class BaseDatabaseFeatures(object):
    4343    allows_group_by_ordinal = True
    44     allows_unique_and_pk = True
    45     autoindexes_primary_keys = True
    4644    needs_datetime_string_cast = True
    4745    needs_upper_for_iops = False
    4846    supports_constraints = True
  • django/core/management/commands/createcachetable.py

     
    2121        for f in fields:
    2222            field_output = [qn(f.name), f.db_type()]
    2323            field_output.append("%sNULL" % (not f.null and "NOT " or ""))
    24             if f.unique:
    25                 field_output.append("UNIQUE")
    2624            if f.primary_key:
    2725                field_output.append("PRIMARY KEY")
     26            elif f.unique:
     27                field_output.append("UNIQUE")
    2828            if f.db_index:
    2929                unique = f.unique and "UNIQUE " or ""
    3030                index_output.append("CREATE %sINDEX %s_%s ON %s (%s);" % \
  • django/core/management/sql.py

     
    263263        field_output = [style.SQL_FIELD(qn(f.column)),
    264264            style.SQL_COLTYPE(col_type)]
    265265        field_output.append(style.SQL_KEYWORD('%sNULL' % (not f.null and 'NOT ' or '')))
    266         if f.unique and (not f.primary_key or connection.features.allows_unique_and_pk):
    267             field_output.append(style.SQL_KEYWORD('UNIQUE'))
    268266        if f.primary_key:
    269267            field_output.append(style.SQL_KEYWORD('PRIMARY KEY'))
    270         if tablespace and connection.features.supports_tablespaces and (f.unique or f.primary_key) and connection.features.autoindexes_primary_keys:
     268        elif f.unique:
     269            field_output.append(style.SQL_KEYWORD('UNIQUE'))
     270        if tablespace and connection.features.supports_tablespaces and f.unique:
    271271            # We must specify the index tablespace inline, because we
    272272            # won't be generating a CREATE INDEX statement for this field.
    273273            field_output.append(connection.ops.tablespace_sql(tablespace, inline=True))
     
    281281            else:
    282282                # We haven't yet created the table to which this field
    283283                # is related, so save it for later.
    284                 pr = pending_references.setdefault(f.rel.to, []).append((model, f))
     284                r = pending_references.setdefault(f.rel.to, []).append((model, f))
    285285        table_output.append(' '.join(field_output))
    286286    if opts.order_with_respect_to:
    287287        table_output.append(style.SQL_FIELD(qn('_order')) + ' ' + \
     
    348348    for f in opts.many_to_many:
    349349        if not isinstance(f.rel, generic.GenericRel):
    350350            tablespace = f.db_tablespace or opts.db_tablespace
    351             if tablespace and connection.features.supports_tablespaces and connection.features.autoindexes_primary_keys:
     351            if tablespace and connection.features.supports_tablespaces:
    352352                tablespace_sql = ' ' + connection.ops.tablespace_sql(tablespace, inline=True)
    353353            else:
    354354                tablespace_sql = ''
     
    427427
    428428    qn = connection.ops.quote_name
    429429    for f in model._meta.fields:
    430         if f.db_index and not ((f.primary_key or f.unique) and connection.features.autoindexes_primary_keys):
     430        if f.db_index and not f.unique:
    431431            unique = f.unique and 'UNIQUE ' or ''
    432432            tablespace = f.db_tablespace or model._meta.db_tablespace
    433433            if tablespace and connection.features.supports_tablespaces:
Back to Top