Ticket #5680: autoindex_combined.diff
File autoindex_combined.diff, 6.7 KB (added by , 17 years ago) |
---|
-
django/db/models/fields/__init__.py
87 87 self.name = name 88 88 self.verbose_name = verbose_name 89 89 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 92 94 # Oracle treats the empty string ('') as null, so coerce the null 93 95 # option whenever '' is a possible value. 94 96 if self.empty_strings_allowed and settings.DATABASE_ENGINE == 'oracle': … … 98 100 self.serialize = serialize 99 101 self.validator_list = validator_list or [] 100 102 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 102 105 self.unique_for_year = unique_for_year 103 106 self._choices = choices or [] 104 107 self.radio_admin = radio_admin -
django/db/backends/mysql_old/base.py
64 64 return getattr(self.cursor, attr) 65 65 66 66 class DatabaseFeatures(BaseDatabaseFeatures): 67 autoindexes_primary_keys = False67 pass 68 68 69 69 class DatabaseOperations(BaseDatabaseOperations): 70 70 def date_extract_sql(self, lookup_type, field_name): -
django/db/backends/mysql/base.py
60 60 # TRADITIONAL will automatically cause most warnings to be treated as errors. 61 61 62 62 class DatabaseFeatures(BaseDatabaseFeatures): 63 autoindexes_primary_keys = False 63 pass 64 64 65 65 class DatabaseOperations(BaseDatabaseOperations): 66 66 def date_extract_sql(self, lookup_type, field_name): -
django/db/backends/oracle/base.py
23 23 24 24 class DatabaseFeatures(BaseDatabaseFeatures): 25 25 allows_group_by_ordinal = False 26 allows_unique_and_pk = False # Suppress UNIQUE/PK for Oracle (ORA-02259)27 26 needs_datetime_string_cast = False 28 27 needs_upper_for_iops = True 29 28 supports_tablespaces = True -
django/db/backends/__init__.py
41 41 42 42 class BaseDatabaseFeatures(object): 43 43 allows_group_by_ordinal = True 44 allows_unique_and_pk = True45 autoindexes_primary_keys = True46 44 needs_datetime_string_cast = True 47 45 needs_upper_for_iops = False 48 46 supports_constraints = True -
django/core/management/commands/createcachetable.py
21 21 for f in fields: 22 22 field_output = [qn(f.name), f.db_type()] 23 23 field_output.append("%sNULL" % (not f.null and "NOT " or "")) 24 if f.unique:25 field_output.append("UNIQUE")26 24 if f.primary_key: 27 25 field_output.append("PRIMARY KEY") 26 elif f.unique: 27 field_output.append("UNIQUE") 28 28 if f.db_index: 29 29 unique = f.unique and "UNIQUE " or "" 30 30 index_output.append("CREATE %sINDEX %s_%s ON %s (%s);" % \ -
django/core/management/sql.py
263 263 field_output = [style.SQL_FIELD(qn(f.column)), 264 264 style.SQL_COLTYPE(col_type)] 265 265 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'))268 266 if f.primary_key: 269 267 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: 271 271 # We must specify the index tablespace inline, because we 272 272 # won't be generating a CREATE INDEX statement for this field. 273 273 field_output.append(connection.ops.tablespace_sql(tablespace, inline=True)) … … 281 281 else: 282 282 # We haven't yet created the table to which this field 283 283 # 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)) 285 285 table_output.append(' '.join(field_output)) 286 286 if opts.order_with_respect_to: 287 287 table_output.append(style.SQL_FIELD(qn('_order')) + ' ' + \ … … 348 348 for f in opts.many_to_many: 349 349 if not isinstance(f.rel, generic.GenericRel): 350 350 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: 352 352 tablespace_sql = ' ' + connection.ops.tablespace_sql(tablespace, inline=True) 353 353 else: 354 354 tablespace_sql = '' … … 427 427 428 428 qn = connection.ops.quote_name 429 429 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: 431 431 unique = f.unique and 'UNIQUE ' or '' 432 432 tablespace = f.db_tablespace or model._meta.db_tablespace 433 433 if tablespace and connection.features.supports_tablespaces: