Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #10215 -- Ensured that there is parity between enter an…

…d 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
  • Loading branch information...
commit 826692568427328400492f899a315b628b18f877 1 parent 1429a3d
Russell Keith-Magee authored October 02, 2010
20  django/core/management/commands/loaddata.py
@@ -118,8 +118,9 @@ def read(self):
118 118
                 self.stderr.write(
119 119
                     self.style.ERROR("Problem installing fixture '%s': %s is not a known serialization format.\n" %
120 120
                         (fixture_name, format)))
121  
-                transaction.rollback(using=using)
122  
-                transaction.leave_transaction_management(using=using)
  121
+                if commit:
  122
+                    transaction.rollback(using=using)
  123
+                    transaction.leave_transaction_management(using=using)
123 124
                 return
124 125
 
125 126
             if os.path.isabs(fixture_name):
@@ -152,8 +153,9 @@ def read(self):
152 153
                             fixture.close()
153 154
                             self.stderr.write(self.style.ERROR("Multiple fixtures named '%s' in %s. Aborting.\n" %
154 155
                                 (fixture_name, humanize(fixture_dir))))
155  
-                            transaction.rollback(using=using)
156  
-                            transaction.leave_transaction_management(using=using)
  156
+                            if commit:
  157
+                                transaction.rollback(using=using)
  158
+                                transaction.leave_transaction_management(using=using)
157 159
                             return
158 160
                         else:
159 161
                             fixture_count += 1
@@ -178,8 +180,9 @@ def read(self):
178 180
                             except Exception:
179 181
                                 import traceback
180 182
                                 fixture.close()
181  
-                                transaction.rollback(using=using)
182  
-                                transaction.leave_transaction_management(using=using)
  183
+                                if commit:
  184
+                                    transaction.rollback(using=using)
  185
+                                    transaction.leave_transaction_management(using=using)
183 186
                                 if show_traceback:
184 187
                                     traceback.print_exc()
185 188
                                 else:
@@ -196,8 +199,9 @@ def read(self):
196 199
                                 self.stderr.write(
197 200
                                     self.style.ERROR("No fixture data found for '%s'. (File format may be invalid.)\n" %
198 201
                                         (fixture_name)))
199  
-                                transaction.rollback(using=using)
200  
-                                transaction.leave_transaction_management(using=using)
  202
+                                if commit:
  203
+                                    transaction.rollback(using=using)
  204
+                                    transaction.leave_transaction_management(using=using)
201 205
                                 return
202 206
 
203 207
                     except Exception, e:

0 notes on commit 8266925

Please sign in to comment.
Something went wrong with that request. Please try again.