mirror of
https://github.com/django/django.git
synced 2025-07-05 10:19:20 +00:00
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
This commit is contained in:
parent
fe8c54a62a
commit
61aaccf46d
@ -250,7 +250,9 @@ def _get_sql_for_pending_references(model, pending_references):
|
|||||||
r_col = f.column
|
r_col = f.column
|
||||||
table = opts.db_table
|
table = opts.db_table
|
||||||
col = opts.get_field(f.rel.field_name).column
|
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;' % \
|
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_table), truncate_name(r_name, backend.get_max_name_length()),
|
||||||
backend.quote_name(r_col), backend.quote_name(table), backend.quote_name(col),
|
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
|
col = f.column
|
||||||
r_table = model._meta.db_table
|
r_table = model._meta.db_table
|
||||||
r_col = model._meta.get_field(f.rel.field_name).column
|
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;' % \
|
output.append('%s %s %s %s;' % \
|
||||||
(style.SQL_KEYWORD('ALTER TABLE'),
|
(style.SQL_KEYWORD('ALTER TABLE'),
|
||||||
style.SQL_TABLE(backend.quote_name(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):
|
def get_sql_indexes_for_model(model):
|
||||||
"Returns the CREATE INDEX SQL statements for a single model"
|
"Returns the CREATE INDEX SQL statements for a single model"
|
||||||
from django.db import backend
|
from django.db import backend
|
||||||
from django.db.backends.util import truncate_name
|
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
for f in model._meta.fields:
|
for f in model._meta.fields:
|
||||||
|
@ -199,7 +199,7 @@ def get_pk_default_value():
|
|||||||
return "DEFAULT"
|
return "DEFAULT"
|
||||||
|
|
||||||
def get_max_name_length():
|
def get_max_name_length():
|
||||||
return 64;
|
return None;
|
||||||
|
|
||||||
def get_start_transaction_sql():
|
def get_start_transaction_sql():
|
||||||
return "BEGIN;"
|
return "BEGIN;"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user