Changeset 9053
- Timestamp:
- 09/17/08 00:12:53 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/commands/inspectdb.py
r8404 r9053 42 42 indexes = {} 43 43 for i, row in enumerate(connection.introspection.get_table_description(cursor, table_name)): 44 att_name = row[0].lower() 44 column_name = row[0] 45 att_name = column_name.lower() 45 46 comment_notes = [] # Holds Field notes, to be displayed in a Python comment. 46 47 extra_params = {} # Holds Field parameters such as 'db_column'. 47 48 48 # If we need to do field name modifiations,49 # remember the original field name50 if ' ' in att_name or '-' in att_name or keyword.iskeyword(att_name) :51 extra_params['db_column'] = att_name52 53 # Now modify the field name to make it python compatible.49 # If the column name can't be used verbatim as a Python 50 # attribute, set the "db_column" for this Field. 51 if ' ' in att_name or '-' in att_name or keyword.iskeyword(att_name) or column_name != att_name: 52 extra_params['db_column'] = column_name 53 54 # Modify the field name to make it Python-compatible. 54 55 if ' ' in att_name: 55 56 att_name = att_name.replace(' ', '_') … … 61 62 att_name += '_field' 62 63 comment_notes.append('Field renamed because it was a Python reserved word.') 64 if column_name != att_name: 65 comment_notes.append('Field name made lowercase.') 63 66 64 67 if i in relations: … … 68 71 att_name = att_name[:-3] 69 72 else: 70 extra_params['db_column'] = att_name73 extra_params['db_column'] = column_name 71 74 else: 72 75 try: … … 91 94 92 95 # Add primary_key and unique, if necessary. 93 column_name = extra_params.get('db_column', att_name)94 96 if column_name in indexes: 95 97 if indexes[column_name]['primary_key']:
