summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-03-22 14:36:01 +0100
committerTim Graham <timograham@gmail.com>2014-07-24 19:18:06 -0400
commit0ac986fd8cb2561a22aa3291672723b50397e5ac (patch)
treeab0a4e39b62c8340755dfe10edb084fcdd8f6548
parent2a97db33a79c0be179b5bc35860400287f1ae26a (diff)
[1.7.x] Avoided transactional truncates on amateur databases.
Fixed a test failure that appeared after 753a22a6, although the bug existed before that commit. Refs #22308. Backport of 6877a9d4 from master
-rw-r--r--django/core/management/commands/flush.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index 32c7aa0743..29e3a8ec58 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -27,8 +27,8 @@ class Command(NoArgsCommand):
'fixture reloaded. Does not achieve a "fresh install" state.')
def handle_noargs(self, **options):
- db = options.get('database')
- connection = connections[db]
+ database = options.get('database')
+ connection = connections[database]
verbosity = int(options.get('verbosity'))
interactive = options.get('interactive')
# The following are stealth options used by Django's internals.
@@ -62,7 +62,8 @@ Are you sure you want to do this?
if confirm == 'yes':
try:
- with transaction.atomic(using=db):
+ with transaction.atomic(using=database,
+ savepoint=connection.features.can_rollback_ddl):
with connection.cursor() as cursor:
for sql in sql_list:
cursor.execute(sql)
@@ -77,7 +78,7 @@ Are you sure you want to do this?
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
if not inhibit_post_migrate:
- self.emit_post_migrate(verbosity, interactive, db)
+ self.emit_post_migrate(verbosity, interactive, database)
# Reinstall the initial_data fixture.
if options.get('load_initial_data'):