Changeset 5027
- Timestamp:
- 04/18/07 17:40:53 (2 years ago)
- Files:
-
- django/branches/boulder-oracle-sprint/django/core/management.py (modified) (7 diffs)
- django/branches/boulder-oracle-sprint/django/db/backends/ado_mssql/base.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/db/backends/mysql/base.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/db/backends/postgresql/base.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/db/backends/postgresql_psycopg2/base.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/django/core/management.py
r5022 r5027 179 179 data_type = f.get_internal_type() 180 180 col_type = data_types[data_type] 181 tablespace = f.tablespace or opts.tablespace 181 182 if col_type is not None: 182 183 # Make the definition (e.g. 'foo VARCHAR(30)') for this field. … … 188 189 if f.primary_key: 189 190 field_output.append(style.SQL_KEYWORD('PRIMARY KEY')) 191 if tablespace and backend.supports_tablespaces and (f.unique or f.primary_key) and backend.autoindexes_primary_keys: 192 # We must specify the index tablespace inline, because we 193 # won't be generating a CREATE INDEX statement for this field. 194 field_output.append(backend.get_tablespace_sql(tablespace, inline=True)) 190 195 if f.rel: 191 196 if f.rel.to in known_models: … … 213 218 full_statement.append(')') 214 219 if opts.tablespace and backend.supports_tablespaces: 215 full_statement.append(backend.get_tablespace_sql( ) % backend.quote_name(opts.tablespace))220 full_statement.append(backend.get_tablespace_sql(opts.tablespace)) 216 221 full_statement.append(';') 217 222 final_output.append('\n'.join(full_statement)) … … 262 267 for f in opts.many_to_many: 263 268 if not isinstance(f.rel, GenericRel): 269 tablespace = f.tablespace or opts.tablespace 270 if tablespace and backend.supports_tablespaces and backend.autoindexes_primary_keys: 271 tablespace_sql = ' ' + backend.get_tablespace_sql(tablespace, inline=True) 272 else: 273 tablespace_sql = '' 264 274 table_output = [style.SQL_KEYWORD('CREATE TABLE') + ' ' + \ 265 275 style.SQL_TABLE(backend.quote_name(f.m2m_db_table())) + ' ('] 266 table_output.append(' %s %s %s ,' % \276 table_output.append(' %s %s %s%s,' % \ 267 277 (style.SQL_FIELD(backend.quote_name('id')), 268 278 style.SQL_COLTYPE(data_types['AutoField']), 269 style.SQL_KEYWORD('NOT NULL PRIMARY KEY'))) 279 style.SQL_KEYWORD('NOT NULL PRIMARY KEY'), 280 tablespace_sql)) 270 281 table_output.append(' %s %s %s %s (%s)%s,' % \ 271 282 (style.SQL_FIELD(backend.quote_name(f.m2m_column_name())), … … 282 293 style.SQL_FIELD(backend.quote_name(f.rel.to._meta.pk.column)), 283 294 backend.get_deferrable_sql())) 284 table_output.append(' %s (%s, %s) ' % \295 table_output.append(' %s (%s, %s)%s' % \ 285 296 (style.SQL_KEYWORD('UNIQUE'), 286 297 style.SQL_FIELD(backend.quote_name(f.m2m_column_name())), 287 style.SQL_FIELD(backend.quote_name(f.m2m_reverse_name())))) 298 style.SQL_FIELD(backend.quote_name(f.m2m_reverse_name())), 299 tablespace_sql)) 288 300 table_output.append(')') 289 301 if opts.tablespace and backend.supports_tablespaces: 290 table_output.append(backend.get_tablespace_sql() % opts.tablespace) 302 # f.tablespace is only for indices, so ignore its value here. 303 table_output.append(backend.get_tablespace_sql(opts.tablespace)) 291 304 table_output.append(';') 292 305 final_output.append('\n'.join(table_output)) … … 469 482 470 483 for f in model._meta.fields: 471 if f.db_index and not ( f.primary_keyand backend.autoindexes_primary_keys):484 if f.db_index and not ((f.primary_key or f.unique) and backend.autoindexes_primary_keys): 472 485 unique = f.unique and 'UNIQUE ' or '' 486 tablespace = f.tablespace or model._meta.tablespace 487 if tablespace and backend.supports_tablespaces: 488 tablespace_sql = ' ' + backend.get_tablespace_sql(tablespace) 489 else: 490 tablespace_sql = '' 473 491 output.append( 474 492 style.SQL_KEYWORD('CREATE %sINDEX' % unique) + ' ' + \ … … 476 494 style.SQL_KEYWORD('ON') + ' ' + \ 477 495 style.SQL_TABLE(backend.quote_name(model._meta.db_table)) + ' ' + \ 478 "(%s);" % style.SQL_FIELD(backend.quote_name(f.column)) 496 "(%s)" % style.SQL_FIELD(backend.quote_name(f.column)) + \ 497 "%s;" % tablespace_sql 479 498 ) 480 499 return output django/branches/boulder-oracle-sprint/django/db/backends/ado_mssql/base.py
r5026 r5027 155 155 return "BEGIN;" 156 156 157 def get_tablespace_sql( ):158 return "ON %s" 157 def get_tablespace_sql(tablespace, inline=False): 158 return "ON %s" % quote_name(tablespace) 159 159 160 160 def get_autoinc_sql(table): django/branches/boulder-oracle-sprint/django/db/backends/mysql/base.py
r5022 r5027 138 138 needs_upper_for_iops = False 139 139 supports_constraints = True 140 supports_tablespaces = True140 supports_tablespaces = False 141 141 uses_case_insensitive_names = False 142 142 … … 201 201 def get_start_transaction_sql(): 202 202 return "BEGIN;" 203 204 def get_tablespace_sql():205 return "TABLESPACE %s STORAGE DISK"206 203 207 204 def get_autoinc_sql(table): django/branches/boulder-oracle-sprint/django/db/backends/oracle/base.py
r5024 r5027 170 170 return None 171 171 172 def get_tablespace_sql( ):173 return " TABLESPACE %s"172 def get_tablespace_sql(tablespace, inline=False): 173 return "%sTABLESPACE %s" % ((inline and "USING INDEX " or ""), quote_name(tablespace)) 174 174 175 175 def get_autoinc_sql(table): django/branches/boulder-oracle-sprint/django/db/backends/postgresql/base.py
r5026 r5027 111 111 needs_upper_for_iops = False 112 112 supports_constraints = True 113 supports_tablespaces = True113 supports_tablespaces = False 114 114 uses_case_insensitive_names = False 115 115 … … 174 174 def get_start_transaction_sql(): 175 175 return "BEGIN;" 176 177 def get_tablespace_sql():178 return "TABLESPACE %s"179 176 180 177 def get_autoinc_sql(table): django/branches/boulder-oracle-sprint/django/db/backends/postgresql_psycopg2/base.py
r5026 r5027 79 79 needs_upper_for_iops = False 80 80 supports_constraints = True 81 supports_tablespaces = True81 supports_tablespaces = False 82 82 uses_case_insensitive_names = True 83 83 … … 134 134 def get_start_transaction_sql(): 135 135 return "BEGIN;" 136 137 def get_tablespace_sql():138 return "TABLESPACE %s"139 136 140 137 def get_autoinc_sql(table): django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
r5021 r5027 71 71 prepopulate_from=None, unique_for_date=None, unique_for_month=None, 72 72 unique_for_year=None, validator_list=None, choices=None, radio_admin=None, 73 help_text='', db_column=None ):73 help_text='', db_column=None, tablespace=None): 74 74 self.name = name 75 75 self.verbose_name = verbose_name … … 88 88 self.help_text = help_text 89 89 self.db_column = db_column 90 self.tablespace = tablespace 90 91 91 92 # Set db_index to True if the field has a relationship and doesn't explicitly set db_index.
