Django

Code

Changeset 5779

Show
Ignore:
Timestamp:
07/30/07 15:05:02 (1 year ago)
Author:
danderson
Message:

schema-evolution: fixed f.aka bug; moved sql commenting from the base classes into management.py; added unit tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/django/core/management.py

    r5777 r5779  
    564564    for f in opts.fields: 
    565565        existing_fields = introspection.get_columns(cursor,db_table) 
    566         if f.column not in existing_fields and f.aka and f.aka not in existing_fields and len(set(f.aka) & set(existing_fields))==0
     566        if f.column not in existing_fields and (not f.aka or f.aka not in existing_fields and len(set(f.aka) & set(existing_fields))==0)
    567567            rel_field = f 
    568568            data_type = f.get_internal_type() 
     
    703703        output.append( '-- warning: as the following may cause data loss, it/they must be run manually' ) 
    704704        for suspect_field in suspect_fields: 
    705             output.append( backend.get_drop_column_sql( db_table, suspect_field ) ) 
     705            output.append( '-- '+ backend.get_drop_column_sql( db_table, suspect_field ) ) 
    706706        output.append( '-- end warning' ) 
    707707    return output 
  • django/branches/schema-evolution/django/db/backends/mysql/base.py

    r5735 r5779  
    281281def get_drop_column_sql( table_name, col_name ): 
    282282    output = [] 
    283     output.append( '-- ALTER TABLE '+ quote_name(table_name) +' DROP COLUMN '+ quote_name(col_name) + ';' ) 
     283    output.append( 'ALTER TABLE '+ quote_name(table_name) +' DROP COLUMN '+ quote_name(col_name) + ';' ) 
    284284    return '\n'.join(output) 
    285285     
  • django/branches/schema-evolution/django/db/backends/postgresql/base.py

    r5735 r5779  
    316316def get_drop_column_sql( table_name, col_name ): 
    317317    output = [] 
    318     output.append( '-- ALTER TABLE '+ quote_name(table_name) +' DROP COLUMN '+ quote_name(col_name) + ';' ) 
     318    output.append( 'ALTER TABLE '+ quote_name(table_name) +' DROP COLUMN '+ quote_name(col_name) + ';' ) 
    319319    return '\n'.join(output) 
    320320