From 9b8ffa9c6a81c931c3e2a91d065aeff7a7837895 Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Fri, 26 Jun 2015 13:33:55 +0100 Subject: [PATCH] added if block to check if the connection supports atomic transactions --- django/core/management/commands/flush.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py index 82dd246160ff..5fde7f7fe459 100644 --- a/django/core/management/commands/flush.py +++ b/django/core/management/commands/flush.py @@ -63,11 +63,18 @@ def handle_noargs(self, **options): if confirm == 'yes': try: - with transaction.atomic(using=database, - savepoint=connection.features.can_rollback_ddl): + + if connection.features.atomic_transactions: + with transaction.atomic(using=database, + savepoint=connection.features.can_rollback_ddl): + cursor = connection.cursor() + for sql in sql_list: + cursor.execute(sql) + else: cursor = connection.cursor() for sql in sql_list: cursor.execute(sql) + except Exception as e: new_msg = ( "Database %s couldn't be flushed. Possible reasons:\n"