Ticket #8317: primary_fk.diff
File primary_fk.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/core/management/commands/inspectdb.py
45 45 comment_notes = [] # Holds Field notes, to be displayed in a Python comment. 46 46 extra_params = {} # Holds Field parameters such as 'db_column'. 47 47 48 # Add primary_key and unique, if necessary. 49 if att_name in indexes: 50 if indexes[att_name]['primary_key']: 51 extra_params['primary_key'] = True 52 elif indexes[att_name]['unique']: 53 extra_params['unique'] = True 54 48 55 if ' ' in att_name: 49 56 extra_params['db_column'] = att_name 50 57 att_name = att_name.replace(' ', '') … … 82 89 extra_params['max_digits'] = row[4] 83 90 extra_params['decimal_places'] = row[5] 84 91 85 # Add primary_key and unique, if necessary.86 column_name = extra_params.get('db_column', att_name)87 if column_name in indexes:88 if indexes[column_name]['primary_key']:89 extra_params['primary_key'] = True90 elif indexes[column_name]['unique']:91 extra_params['unique'] = True92 93 92 field_type += '(' 94 93 95 94 # Don't output 'id = meta.AutoField(primary_key=True)', because