Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #10215 -- Ensured that there is parity between enter and leave …

…transaction calls in loaddata when commit=False. The test case for this is the fixtures_regress unittests under MyISAM, which were failing previous to this fix. Thanks to MockSoul for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13978 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 96c11b29bda6dab710925827f78445d92beaa5df 1 parent 57456c5
@freakboy3742 freakboy3742 authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 django/core/management/commands/loaddata.py
View
20 django/core/management/commands/loaddata.py
@@ -118,8 +118,9 @@ def read(self):
self.stderr.write(
self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format.\n" %
(fixture_name, format)))
- transaction.rollback(using=using)
- transaction.leave_transaction_management(using=using)
+ if commit:
+ transaction.rollback(using=using)
+ transaction.leave_transaction_management(using=using)
return
if os.path.isabs(fixture_name):
@@ -152,8 +153,9 @@ def read(self):
fixture.close()
self.stderr.write(self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting.\n" %
(fixture_name, humanize(fixture_dir))))
- transaction.rollback(using=using)
- transaction.leave_transaction_management(using=using)
+ if commit:
+ transaction.rollback(using=using)
+ transaction.leave_transaction_management(using=using)
return
else:
fixture_count += 1
@@ -178,8 +180,9 @@ def read(self):
except Exception:
import traceback
fixture.close()
- transaction.rollback(using=using)
- transaction.leave_transaction_management(using=using)
+ if commit:
+ transaction.rollback(using=using)
+ transaction.leave_transaction_management(using=using)
if show_traceback:
traceback.print_exc()
else:
@@ -196,8 +199,9 @@ def read(self):
self.stderr.write(
self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)\n" %
(fixture_name)))
- transaction.rollback(using=using)
- transaction.leave_transaction_management(using=using)
+ if commit:
+ transaction.rollback(using=using)
+ transaction.leave_transaction_management(using=using)
return
except Exception, e:
Please sign in to comment.
Something went wrong with that request. Please try again.