Changeset 5423
- Timestamp:
- 06/04/07 16:10:33 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/django/core/management.py
r5384 r5423 251 251 table = opts.db_table 252 252 col = opts.get_field(f.rel.field_name).column 253 r_name = '%s_refs_%s_%s_%s' % (r_col, col, r_table, table) 253 # For MySQL, r_name must be unique in the first 64 characters. 254 # So we are careful with character usage here. 255 r_name = '%s_refs_%s_%x' % (r_col, col, abs(hash((r_table, table)))) 254 256 final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' % \ 255 257 (backend.quote_name(r_table), truncate_name(r_name, backend.get_max_name_length()), … … 365 367 r_table = model._meta.db_table 366 368 r_col = model._meta.get_field(f.rel.field_name).column 367 r_name = '%s_refs_%s_% s_%s' % (col, r_col, table, r_table)369 r_name = '%s_refs_%s_%x' % (col, r_col, abs(hash(table, r_table))) 368 370 output.append('%s %s %s %s;' % \ 369 371 (style.SQL_KEYWORD('ALTER TABLE'), … … 480 482 "Returns the CREATE INDEX SQL statements for a single model" 481 483 from django.db import backend 482 from django.db.backends.util import truncate_name483 484 output = [] 484 485 … … 1464 1465 print "No %s fixture '%s' in %s." % \ 1465 1466 (format, fixture_name, humanize(fixture_dir)) 1466 1467 1467 1468 if count[0] > 0: 1468 1469 sequence_sql = backend.get_sql_sequence_reset(style, models) … … 1472 1473 for line in sequence_sql: 1473 1474 cursor.execute(line) 1474 1475 1475 1476 transaction.commit() 1476 1477 transaction.leave_transaction_management() 1477 1478 1478 1479 if count[0] == 0: 1479 1480 if verbosity > 0: django/branches/boulder-oracle-sprint/django/db/backends/mysql/base.py
r5307 r5423 200 200 201 201 def get_max_name_length(): 202 return 64;202 return None; 203 203 204 204 def get_start_transaction_sql():
