Moved the space check from r3549 to before the Python keyword check so that

perverse column names like "fin ally" don't fall through the cracks.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3550 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2006-08-11 02:22:42 +00:00
parent caa51f4444
commit 01983c8fc3
1 changed files with 4 additions and 4 deletions

View File

@ -729,14 +729,14 @@ def inspectdb():
comment_notes = [] # Holds Field notes, to be displayed in a Python comment. comment_notes = [] # Holds Field notes, to be displayed in a Python comment.
extra_params = {} # Holds Field parameters such as 'db_column'. extra_params = {} # Holds Field parameters such as 'db_column'.
if ' ' in att_name:
extra_params['db_column'] = att_name
att_name = att_name.replace(' ', '')
comment_notes.append('Field renamed to remove spaces.')
if keyword.iskeyword(att_name): if keyword.iskeyword(att_name):
extra_params['db_column'] = att_name extra_params['db_column'] = att_name
att_name += '_field' att_name += '_field'
comment_notes.append('Field renamed because it was a Python reserved word.') comment_notes.append('Field renamed because it was a Python reserved word.')
elif ' ' in att_name:
extra_params['db_column'] = att_name
att_name = att_name.replace(' ', '')
comment_notes.append('Field renamed to remove spaces.')
if relations.has_key(i): if relations.has_key(i):
rel_to = relations[i][1] == table_name and "'self'" or table2model(relations[i][1]) rel_to = relations[i][1] == table_name and "'self'" or table2model(relations[i][1])