Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoided transactional truncates on amateur databases.

Fixed a test failure that appeared after 753a22a, although the bug
existed before that commit.

Refs #22308.
  • Loading branch information...
commit 6877a9d4156baa3a0c22288c7ef920915b6e1cf8 1 parent ee4edb1
Aymeric Augustin aaugustin authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 django/core/management/commands/flush.py
9 django/core/management/commands/flush.py
View
@@ -28,8 +28,8 @@ class Command(NoArgsCommand):
're-executed, and the initial_data fixture will be re-installed.')
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.
@@ -63,7 +63,8 @@ def handle_noargs(self, **options):
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)
@@ -78,7 +79,7 @@ def handle_noargs(self, **options):
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'):
Please sign in to comment.
Something went wrong with that request. Please try again.