Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

boulder-oracle-sprint: Fixes #4055: Added "tablespace" parameter to m…

…odel 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
  • Loading branch information...
commit e558b9aac4e935320c828416d6bb2aae3ed88f36 1 parent 99b7f9c
Boulder Sprinters authored
12 django/core/management.py
View
@@ -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)) + ' (']
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(');')
+ 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))
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_FIELD(backend.quote_name(f.m2m_column_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))
# 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
count = [0,0]
models = set()
-
+
humanize = lambda dirname: dirname and "'%s'" % dirname or 'absolute path'
# Get a cursor (even though we don't need one yet). This has
4 django/db/backends/ado_mssql/base.py
View
@@ -94,6 +94,7 @@ def close(self):
needs_datetime_string_cast = True
needs_upper_for_iops = False
supports_constraints = True
+supports_tablespaces = True
uses_case_insensitive_names = False
def quote_name(name):
@@ -153,6 +154,9 @@ def get_max_name_length():
def get_start_transaction_sql():
return "BEGIN;"
+def get_tablespace_sql():
+ return "ON %s"
+
def get_autoinc_sql(table):
return None
1  django/db/backends/dummy/base.py
View
@@ -27,6 +27,7 @@ def close(self):
pass # close()
supports_constraints = False
+supports_tablespaces = False
quote_name = complain
dictfetchone = complain
dictfetchmany = complain
4 django/db/backends/mysql/base.py
View
@@ -137,6 +137,7 @@ def get_server_version(self):
needs_datetime_string_cast = True # MySQLdb requires a typecast for dates
needs_upper_for_iops = False
supports_constraints = True
+supports_tablespaces = True
uses_case_insensitive_names = False
def quote_name(name):
@@ -200,6 +201,9 @@ def get_max_name_length():
def get_start_transaction_sql():
return "BEGIN;"
+def get_tablespace_sql():
+ return "TABLESPACE %s STORAGE DISK"
+
def get_autoinc_sql(table):
return None
4 django/db/backends/oracle/base.py
View
@@ -72,6 +72,7 @@ def close(self):
needs_datetime_string_cast = False
needs_upper_for_iops = True
supports_constraints = True
+supports_tablespaces = True
uses_case_insensitive_names = True
class FormatStylePlaceholderCursor(Database.Cursor):
@@ -168,6 +169,9 @@ def get_max_name_length():
def get_start_transaction_sql():
return None
+def get_tablespace_sql():
+ return "TABLESPACE %s"
+
def get_autoinc_sql(table):
# To simulate auto-incrementing primary keys in Oracle, we have to
# create a sequence and a trigger.
4 django/db/backends/postgresql/base.py
View
@@ -110,6 +110,7 @@ def close(self):
needs_datetime_string_cast = True
needs_upper_for_iops = False
supports_constraints = True
+supports_tablespaces = True
uses_case_insensitive_names = False
def quote_name(name):
@@ -173,6 +174,9 @@ def get_max_name_length():
def get_start_transaction_sql():
return "BEGIN;"
+def get_tablespace_sql():
+ return "TABLESPACE %s"
+
def get_autoinc_sql(table):
return None
4 django/db/backends/postgresql_psycopg2/base.py
View
@@ -78,6 +78,7 @@ def close(self):
needs_datetime_string_cast = False
needs_upper_for_iops = False
supports_constraints = True
+supports_tablespaces = True
uses_case_insensitive_names = True
def quote_name(name):
@@ -133,6 +134,9 @@ def get_max_name_length():
def get_start_transaction_sql():
return "BEGIN;"
+def get_tablespace_sql():
+ return "TABLESPACE %s"
+
def get_autoinc_sql(table):
return None
3  django/db/backends/sqlite3/base.py
View
@@ -105,6 +105,7 @@ def convert_query(self, query, num_params):
needs_datetime_string_cast = True
needs_upper_for_iops = False
supports_constraints = False
+supports_tablespaces = False
uses_case_insensitive_names = False
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."
# No sequence reset required
return []
-
+
def _sqlite_date_trunc(lookup_type, dt):
try:
dt = util.typecast_timestamp(dt)
7 django/db/models/options.py
View
@@ -13,7 +13,7 @@
DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
'unique_together', 'permissions', 'get_latest_by',
- 'order_with_respect_to', 'app_label')
+ 'order_with_respect_to', 'app_label', 'tablespace')
class Options(object):
def __init__(self, meta):
@@ -27,6 +27,7 @@ def __init__(self, meta):
self.object_name, self.app_label = None, None
self.get_latest_by = None
self.order_with_respect_to = None
+ self.tablespace = None
self.admin = None
self.meta = meta
self.pk = None
@@ -92,10 +93,10 @@ def add_field(self, field):
def __repr__(self):
return '<Options for %s>' % self.object_name
-
+
def __str__(self):
return "%s.%s" % (self.app_label, self.module_name)
-
+
def get_field(self, name, many_to_many=True):
"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
Please sign in to comment.
Something went wrong with that request. Please try again.