Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added if block to check if the connection supports atomic transactions #22

Open
wants to merge 1 commit into
base: nonrel-1.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions django/core/management/commands/flush.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down