diff -r f561ce6b959a django/core/management/commands/inspectdb.py
a
|
b
|
class Command(NoArgsCommand):
|
41 | 41 | except NotImplementedError: |
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 | 49 | # If we need to do field name modifiations, |
49 | 50 | # remember the original field name |
50 | 51 | if ' ' in att_name or '-' in att_name or keyword.iskeyword(att_name): |
51 | | extra_params['db_column'] = att_name |
| 52 | extra_params['db_column'] = column_name |
52 | 53 | |
53 | 54 | # Now modify the field name to make it python compatible. |
54 | 55 | if ' ' in att_name: |
… |
… |
class Command(NoArgsCommand):
|
67 | 68 | if att_name.endswith('_id'): |
68 | 69 | att_name = att_name[:-3] |
69 | 70 | else: |
70 | | extra_params['db_column'] = att_name |
| 71 | extra_params['db_column'] = column_name |
71 | 72 | else: |
72 | 73 | try: |
73 | 74 | field_type = connection.introspection.data_types_reverse[row[1]] |
… |
… |
class Command(NoArgsCommand):
|
90 | 91 | extra_params['decimal_places'] = row[5] |
91 | 92 | |
92 | 93 | # Add primary_key and unique, if necessary. |
93 | | column_name = extra_params.get('db_column', att_name) |
94 | 94 | if column_name in indexes: |
95 | 95 | if indexes[column_name]['primary_key']: |
96 | 96 | extra_params['primary_key'] = True |