Changed django.core.management.get_sql_delete to be more robust when many-to-many tables don't exist

git-svn-id: http://code.djangoproject.com/svn/django/trunk@330 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-07-26 23:18:08 +00:00
parent d8ef66b17d
commit d52db2d879
1 changed files with 2 additions and 2 deletions

View File

@ -119,7 +119,7 @@ def get_sql_delete(mod):
cursor.execute("SELECT 1 FROM %s LIMIT 1" % klass._meta.db_table) cursor.execute("SELECT 1 FROM %s LIMIT 1" % klass._meta.db_table)
except: except:
# The table doesn't exist, so it doesn't need to be dropped. # The table doesn't exist, so it doesn't need to be dropped.
pass db.db.rollback()
else: else:
output.append("DROP TABLE %s;" % klass._meta.db_table) output.append("DROP TABLE %s;" % klass._meta.db_table)
for klass in mod._MODELS: for klass in mod._MODELS:
@ -129,7 +129,7 @@ def get_sql_delete(mod):
if cursor is not None: if cursor is not None:
cursor.execute("SELECT 1 FROM %s LIMIT 1" % f.get_m2m_db_table(opts)) cursor.execute("SELECT 1 FROM %s LIMIT 1" % f.get_m2m_db_table(opts))
except: except:
pass db.db.rollback()
else: else:
output.append("DROP TABLE %s;" % f.get_m2m_db_table(opts)) output.append("DROP TABLE %s;" % f.get_m2m_db_table(opts))