Ticket #5671: unique.diff
File unique.diff, 4.8 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/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 44 autoindexes_primary_keys = True 46 45 needs_datetime_string_cast = True 47 46 needs_upper_for_iops = False -
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 and connection.features.autoindexes_primary_keys: 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)) … … 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 and connection.features.autoindexes_primary_keys): 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: