Django

Code

Changeset 5423

Show
Ignore:
Timestamp:
06/04/07 16:10:33 (1 year ago)
Author:
bouldersprinters
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/django/core/management.py

    r5384 r5423  
    251251                table = opts.db_table 
    252252                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)))) 
    254256                final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' % \ 
    255257                    (backend.quote_name(r_table), truncate_name(r_name, backend.get_max_name_length()), 
     
    365367                    r_table = model._meta.db_table 
    366368                    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))
    368370                    output.append('%s %s %s %s;' % \ 
    369371                        (style.SQL_KEYWORD('ALTER TABLE'), 
     
    480482    "Returns the CREATE INDEX SQL statements for a single model" 
    481483    from django.db import backend 
    482     from django.db.backends.util import truncate_name 
    483484    output = [] 
    484485 
     
    14641465                        print "No %s fixture '%s' in %s." % \ 
    14651466                            (format, fixture_name, humanize(fixture_dir)) 
    1466                              
     1467 
    14671468    if count[0] > 0: 
    14681469        sequence_sql = backend.get_sql_sequence_reset(style, models) 
     
    14721473            for line in sequence_sql: 
    14731474                cursor.execute(line) 
    1474              
     1475 
    14751476    transaction.commit() 
    14761477    transaction.leave_transaction_management() 
    1477      
     1478 
    14781479    if count[0] == 0: 
    14791480        if verbosity > 0: 
  • django/branches/boulder-oracle-sprint/django/db/backends/mysql/base.py

    r5307 r5423  
    200200 
    201201def get_max_name_length(): 
    202     return 64
     202    return None
    203203 
    204204def get_start_transaction_sql():