summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-06-04 21:10:33 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-06-04 21:10:33 +0000
commit61aaccf46df3926f488f68df7748051bbc3131b8 (patch)
tree053a9031f23f10e9e02cd18987c2b2002d967209
parentfe8c54a62a43b08b10ba343603d2b80e54d320b9 (diff)
downloaddjango-61aaccf46df3926f488f68df7748051bbc3131b8.tar.gz
boulder-oracle-sprint: Reverted constraint name construction to that used in the trunk.
Made the mysql backend return None for get_max_name_length() for backwards compatibility. git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5423 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management.py13
-rw-r--r--django/db/backends/mysql/base.py2
2 files changed, 8 insertions, 7 deletions
diff --git a/django/core/management.py b/django/core/management.py
index 3d7f8431be..4d886b2bb2 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -250,7 +250,9 @@ def _get_sql_for_pending_references(model, pending_references):
r_col = f.column
table = opts.db_table
col = opts.get_field(f.rel.field_name).column
- r_name = '%s_refs_%s_%s_%s' % (r_col, col, r_table, table)
+ # For MySQL, r_name must be unique in the first 64 characters.
+ # So we are careful with character usage here.
+ r_name = '%s_refs_%s_%x' % (r_col, col, abs(hash((r_table, table))))
final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' % \
(backend.quote_name(r_table), truncate_name(r_name, backend.get_max_name_length()),
backend.quote_name(r_col), backend.quote_name(table), backend.quote_name(col),
@@ -364,7 +366,7 @@ def get_sql_delete(app):
col = f.column
r_table = model._meta.db_table
r_col = model._meta.get_field(f.rel.field_name).column
- r_name = '%s_refs_%s_%s_%s' % (col, r_col, table, r_table)
+ r_name = '%s_refs_%s_%x' % (col, r_col, abs(hash(table, r_table)))
output.append('%s %s %s %s;' % \
(style.SQL_KEYWORD('ALTER TABLE'),
style.SQL_TABLE(backend.quote_name(table)),
@@ -479,7 +481,6 @@ get_sql_indexes.args = APP_ARGS
def get_sql_indexes_for_model(model):
"Returns the CREATE INDEX SQL statements for a single model"
from django.db import backend
- from django.db.backends.util import truncate_name
output = []
for f in model._meta.fields:
@@ -1463,7 +1464,7 @@ def load_data(fixture_labels, verbosity=1):
if verbosity > 1:
print "No %s fixture '%s' in %s." % \
(format, fixture_name, humanize(fixture_dir))
-
+
if count[0] > 0:
sequence_sql = backend.get_sql_sequence_reset(style, models)
if sequence_sql:
@@ -1471,10 +1472,10 @@ def load_data(fixture_labels, verbosity=1):
print "Resetting sequences"
for line in sequence_sql:
cursor.execute(line)
-
+
transaction.commit()
transaction.leave_transaction_management()
-
+
if count[0] == 0:
if verbosity > 0:
print "No fixtures found."
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 503ec9a73c..b0ca7994b7 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -199,7 +199,7 @@ def get_pk_default_value():
return "DEFAULT"
def get_max_name_length():
- return 64;
+ return None;
def get_start_transaction_sql():
return "BEGIN;"