summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-10-02 13:56:58 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-10-02 13:56:58 +0000
commit826692568427328400492f899a315b628b18f877 (patch)
tree95564bf4e6cf3e85b81b33633047f1eca3b97fd0
parent1429a3dbbad29809ad21947d123a64340d74e099 (diff)
[1.2.X] 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.
Backport of r13978 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13979 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/commands/loaddata.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 2bbd9c57b0..b8bb62feca 100644
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -118,8 +118,9 @@ class Command(BaseCommand):
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 @@ class Command(BaseCommand):
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 @@ class Command(BaseCommand):
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 @@ class Command(BaseCommand):
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: