diff options
author | Derek Anderson <public@kered.org> | 2007-07-30 17:10:05 +0000 |
---|---|---|
committer | Derek Anderson <public@kered.org> | 2007-07-30 17:10:05 +0000 |
commit | 993ac8db975aa3544a9f01921dc40b7f3d70d72e (patch) | |
tree | 6edab49f28a78d90fa7c4db08dc7a07a86d22ff6 | |
parent | 05fb38769683497892718fe176d0416cbb3a26e6 (diff) | |
download | django-993ac8db975aa3544a9f01921dc40b7f3d70d72e.tar.gz |
schema-evolution: fixed None iteration error
git-svn-id: http://code.djangoproject.com/svn/django/branches/schema-evolution@5777 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r-- | django/core/management.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/django/core/management.py b/django/core/management.py index 14c9c15c72..050aad88e8 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -563,7 +563,7 @@ def get_sql_evolution_check_for_new_fields(klass, new_table_name): db_table = new_table_name for f in opts.fields: existing_fields = introspection.get_columns(cursor,db_table) - if f.column not in existing_fields and f.aka not in existing_fields and len(set(f.aka) & set(existing_fields))==0: + 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: rel_field = f data_type = f.get_internal_type() col_type = data_types[data_type] @@ -609,7 +609,7 @@ def get_sql_evolution_check_for_changed_field_name(klass, new_table_name): db_table = new_table_name for f in opts.fields: existing_fields = introspection.get_columns(cursor,db_table) - if f.column not in existing_fields and (f.aka in existing_fields or len(set(f.aka) & set(existing_fields)))==1: + if f.column not in existing_fields and f.aka and (f.aka in existing_fields or len(set(f.aka) & set(existing_fields)))==1: old_col = None if isinstance( f.aka, str ): old_col = f.aka @@ -648,7 +648,7 @@ def get_sql_evolution_check_for_changed_field_flags(klass, new_table_name): cf = f.column elif f.aka in existing_fields: cf = f.aka - elif len(set(f.aka) & set(existing_fields))==1: + elif f.aka and len(set(f.aka) & set(existing_fields))==1: cf = f.aka[0] else: continue # no idea what column you're talking about - should be handled by get_sql_evolution_check_for_new_fields()) @@ -692,14 +692,17 @@ def get_sql_evolution_check_for_dead_fields(klass, new_table_name): if new_table_name: db_table = new_table_name suspect_fields = set(introspection.get_columns(cursor,db_table)) +# print 'suspect_fields = ', suspect_fields for f in opts.fields: +# print 'f = ', f +# print 'f.aka = ', f.aka suspect_fields.discard(f.column) suspect_fields.discard(f.aka) - suspect_fields.difference_update(f.aka) + if f.aka: suspect_fields.difference_update(f.aka) if len(suspect_fields)>0: output.append( '-- warning: as the following may cause data loss, it/they must be run manually' ) - for suspect_field in suspect_fields: - output.append( backend.get_drop_column_sql( db_table, suspect_field ) ) + for suspect_field in suspect_fields: + output.append( backend.get_drop_column_sql( db_table, suspect_field ) ) output.append( '-- end warning' ) return output |