mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
boulder-oracle-sprint: Fixes #4055: Added "tablespace" parameter to model metadata options to support specification of tablespaces, primarily for Oracle.
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5022 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
99b7f9c185
commit
e558b9aac4
@ -210,7 +210,10 @@ def _get_sql_model_create(model, known_models=set()):
|
|||||||
full_statement = [style.SQL_KEYWORD('CREATE TABLE') + ' ' + style.SQL_TABLE(backend.quote_name(opts.db_table)) + ' (']
|
full_statement = [style.SQL_KEYWORD('CREATE TABLE') + ' ' + style.SQL_TABLE(backend.quote_name(opts.db_table)) + ' (']
|
||||||
for i, line in enumerate(table_output): # Combine and add commas.
|
for i, line in enumerate(table_output): # Combine and add commas.
|
||||||
full_statement.append(' %s%s' % (line, i < len(table_output)-1 and ',' or ''))
|
full_statement.append(' %s%s' % (line, i < len(table_output)-1 and ',' or ''))
|
||||||
full_statement.append(');')
|
full_statement.append(')')
|
||||||
|
if opts.tablespace and backend.supports_tablespaces:
|
||||||
|
full_statement.append(backend.get_tablespace_sql() % backend.quote_name(opts.tablespace))
|
||||||
|
full_statement.append(';')
|
||||||
final_output.append('\n'.join(full_statement))
|
final_output.append('\n'.join(full_statement))
|
||||||
|
|
||||||
if opts.has_auto_field and hasattr(backend, 'get_autoinc_sql'):
|
if opts.has_auto_field and hasattr(backend, 'get_autoinc_sql'):
|
||||||
@ -282,7 +285,10 @@ def _get_many_to_many_sql_for_model(model):
|
|||||||
(style.SQL_KEYWORD('UNIQUE'),
|
(style.SQL_KEYWORD('UNIQUE'),
|
||||||
style.SQL_FIELD(backend.quote_name(f.m2m_column_name())),
|
style.SQL_FIELD(backend.quote_name(f.m2m_column_name())),
|
||||||
style.SQL_FIELD(backend.quote_name(f.m2m_reverse_name()))))
|
style.SQL_FIELD(backend.quote_name(f.m2m_reverse_name()))))
|
||||||
table_output.append(');')
|
table_output.append(')')
|
||||||
|
if opts.tablespace and backend.supports_tablespaces:
|
||||||
|
table_output.append(backend.get_tablespace_sql() % opts.tablespace)
|
||||||
|
table_output.append(';')
|
||||||
final_output.append('\n'.join(table_output))
|
final_output.append('\n'.join(table_output))
|
||||||
|
|
||||||
# Add any extra SQL needed to support auto-incrementing PKs
|
# Add any extra SQL needed to support auto-incrementing PKs
|
||||||
@ -1355,7 +1361,7 @@ def load_data(fixture_labels, verbosity=1):
|
|||||||
# Keep a count of the installed objects and fixtures
|
# Keep a count of the installed objects and fixtures
|
||||||
count = [0,0]
|
count = [0,0]
|
||||||
models = set()
|
models = set()
|
||||||
|
|
||||||
humanize = lambda dirname: dirname and "'%s'" % dirname or 'absolute path'
|
humanize = lambda dirname: dirname and "'%s'" % dirname or 'absolute path'
|
||||||
|
|
||||||
# Get a cursor (even though we don't need one yet). This has
|
# Get a cursor (even though we don't need one yet). This has
|
||||||
|
@ -94,6 +94,7 @@ autoindexes_primary_keys = False
|
|||||||
needs_datetime_string_cast = True
|
needs_datetime_string_cast = True
|
||||||
needs_upper_for_iops = False
|
needs_upper_for_iops = False
|
||||||
supports_constraints = True
|
supports_constraints = True
|
||||||
|
supports_tablespaces = True
|
||||||
uses_case_insensitive_names = False
|
uses_case_insensitive_names = False
|
||||||
|
|
||||||
def quote_name(name):
|
def quote_name(name):
|
||||||
@ -153,6 +154,9 @@ def get_max_name_length():
|
|||||||
def get_start_transaction_sql():
|
def get_start_transaction_sql():
|
||||||
return "BEGIN;"
|
return "BEGIN;"
|
||||||
|
|
||||||
|
def get_tablespace_sql():
|
||||||
|
return "ON %s"
|
||||||
|
|
||||||
def get_autoinc_sql(table):
|
def get_autoinc_sql(table):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class DatabaseWrapper:
|
|||||||
pass # close()
|
pass # close()
|
||||||
|
|
||||||
supports_constraints = False
|
supports_constraints = False
|
||||||
|
supports_tablespaces = False
|
||||||
quote_name = complain
|
quote_name = complain
|
||||||
dictfetchone = complain
|
dictfetchone = complain
|
||||||
dictfetchmany = complain
|
dictfetchmany = complain
|
||||||
|
@ -137,6 +137,7 @@ autoindexes_primary_keys = False
|
|||||||
needs_datetime_string_cast = True # MySQLdb requires a typecast for dates
|
needs_datetime_string_cast = True # MySQLdb requires a typecast for dates
|
||||||
needs_upper_for_iops = False
|
needs_upper_for_iops = False
|
||||||
supports_constraints = True
|
supports_constraints = True
|
||||||
|
supports_tablespaces = True
|
||||||
uses_case_insensitive_names = False
|
uses_case_insensitive_names = False
|
||||||
|
|
||||||
def quote_name(name):
|
def quote_name(name):
|
||||||
@ -200,6 +201,9 @@ def get_max_name_length():
|
|||||||
def get_start_transaction_sql():
|
def get_start_transaction_sql():
|
||||||
return "BEGIN;"
|
return "BEGIN;"
|
||||||
|
|
||||||
|
def get_tablespace_sql():
|
||||||
|
return "TABLESPACE %s STORAGE DISK"
|
||||||
|
|
||||||
def get_autoinc_sql(table):
|
def get_autoinc_sql(table):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ autoindexes_primary_keys = True
|
|||||||
needs_datetime_string_cast = False
|
needs_datetime_string_cast = False
|
||||||
needs_upper_for_iops = True
|
needs_upper_for_iops = True
|
||||||
supports_constraints = True
|
supports_constraints = True
|
||||||
|
supports_tablespaces = True
|
||||||
uses_case_insensitive_names = True
|
uses_case_insensitive_names = True
|
||||||
|
|
||||||
class FormatStylePlaceholderCursor(Database.Cursor):
|
class FormatStylePlaceholderCursor(Database.Cursor):
|
||||||
@ -168,6 +169,9 @@ def get_max_name_length():
|
|||||||
def get_start_transaction_sql():
|
def get_start_transaction_sql():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_tablespace_sql():
|
||||||
|
return "TABLESPACE %s"
|
||||||
|
|
||||||
def get_autoinc_sql(table):
|
def get_autoinc_sql(table):
|
||||||
# To simulate auto-incrementing primary keys in Oracle, we have to
|
# To simulate auto-incrementing primary keys in Oracle, we have to
|
||||||
# create a sequence and a trigger.
|
# create a sequence and a trigger.
|
||||||
|
@ -110,6 +110,7 @@ autoindexes_primary_keys = False
|
|||||||
needs_datetime_string_cast = True
|
needs_datetime_string_cast = True
|
||||||
needs_upper_for_iops = False
|
needs_upper_for_iops = False
|
||||||
supports_constraints = True
|
supports_constraints = True
|
||||||
|
supports_tablespaces = True
|
||||||
uses_case_insensitive_names = False
|
uses_case_insensitive_names = False
|
||||||
|
|
||||||
def quote_name(name):
|
def quote_name(name):
|
||||||
@ -173,6 +174,9 @@ def get_max_name_length():
|
|||||||
def get_start_transaction_sql():
|
def get_start_transaction_sql():
|
||||||
return "BEGIN;"
|
return "BEGIN;"
|
||||||
|
|
||||||
|
def get_tablespace_sql():
|
||||||
|
return "TABLESPACE %s"
|
||||||
|
|
||||||
def get_autoinc_sql(table):
|
def get_autoinc_sql(table):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ autoindexes_primary_keys = False
|
|||||||
needs_datetime_string_cast = False
|
needs_datetime_string_cast = False
|
||||||
needs_upper_for_iops = False
|
needs_upper_for_iops = False
|
||||||
supports_constraints = True
|
supports_constraints = True
|
||||||
|
supports_tablespaces = True
|
||||||
uses_case_insensitive_names = True
|
uses_case_insensitive_names = True
|
||||||
|
|
||||||
def quote_name(name):
|
def quote_name(name):
|
||||||
@ -133,6 +134,9 @@ def get_max_name_length():
|
|||||||
def get_start_transaction_sql():
|
def get_start_transaction_sql():
|
||||||
return "BEGIN;"
|
return "BEGIN;"
|
||||||
|
|
||||||
|
def get_tablespace_sql():
|
||||||
|
return "TABLESPACE %s"
|
||||||
|
|
||||||
def get_autoinc_sql(table):
|
def get_autoinc_sql(table):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ autoindexes_primary_keys = False
|
|||||||
needs_datetime_string_cast = True
|
needs_datetime_string_cast = True
|
||||||
needs_upper_for_iops = False
|
needs_upper_for_iops = False
|
||||||
supports_constraints = False
|
supports_constraints = False
|
||||||
|
supports_tablespaces = False
|
||||||
uses_case_insensitive_names = False
|
uses_case_insensitive_names = False
|
||||||
|
|
||||||
def quote_name(name):
|
def quote_name(name):
|
||||||
@ -192,7 +193,7 @@ def get_sql_sequence_reset(style, model_list):
|
|||||||
"Returns a list of the SQL statements to reset sequences for the given models."
|
"Returns a list of the SQL statements to reset sequences for the given models."
|
||||||
# No sequence reset required
|
# No sequence reset required
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _sqlite_date_trunc(lookup_type, dt):
|
def _sqlite_date_trunc(lookup_type, dt):
|
||||||
try:
|
try:
|
||||||
dt = util.typecast_timestamp(dt)
|
dt = util.typecast_timestamp(dt)
|
||||||
|
@ -13,7 +13,7 @@ get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|
|
|||||||
|
|
||||||
DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
|
DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
|
||||||
'unique_together', 'permissions', 'get_latest_by',
|
'unique_together', 'permissions', 'get_latest_by',
|
||||||
'order_with_respect_to', 'app_label')
|
'order_with_respect_to', 'app_label', 'tablespace')
|
||||||
|
|
||||||
class Options(object):
|
class Options(object):
|
||||||
def __init__(self, meta):
|
def __init__(self, meta):
|
||||||
@ -27,6 +27,7 @@ class Options(object):
|
|||||||
self.object_name, self.app_label = None, None
|
self.object_name, self.app_label = None, None
|
||||||
self.get_latest_by = None
|
self.get_latest_by = None
|
||||||
self.order_with_respect_to = None
|
self.order_with_respect_to = None
|
||||||
|
self.tablespace = None
|
||||||
self.admin = None
|
self.admin = None
|
||||||
self.meta = meta
|
self.meta = meta
|
||||||
self.pk = None
|
self.pk = None
|
||||||
@ -92,10 +93,10 @@ class Options(object):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Options for %s>' % self.object_name
|
return '<Options for %s>' % self.object_name
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s.%s" % (self.app_label, self.module_name)
|
return "%s.%s" % (self.app_label, self.module_name)
|
||||||
|
|
||||||
def get_field(self, name, many_to_many=True):
|
def get_field(self, name, many_to_many=True):
|
||||||
"Returns the requested field by name. Raises FieldDoesNotExist on error."
|
"Returns the requested field by name. Raises FieldDoesNotExist on error."
|
||||||
to_search = many_to_many and (self.fields + self.many_to_many) or self.fields
|
to_search = many_to_many and (self.fields + self.many_to_many) or self.fields
|
||||||
|
Loading…
x
Reference in New Issue
Block a user