Changeset 7803
- Timestamp:
- 06/30/08 07:18:29 (2 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/commands/loaddata.py
r7653 r7803 163 163 if verbosity > 0: 164 164 print "Installed %d object(s) from %d fixture(s)" % (object_count, fixture_count) 165 166 # Close the DB connection. This is required as a workaround for an 167 # edge case in MySQL: if the same connection is used to 168 # create tables, load data, and query, the query can return 169 # incorrect results. See Django #7572, MySQL #37735. 170 connection.close() django/trunk/tests/regressiontests/fixtures_regress/models.py
r7789 r7803 45 45 data = models.CharField(max_length=10) 46 46 47 # Models to regresison check #7572 48 class Channel(models.Model): 49 name = models.CharField(max_length=255) 50 51 class Article(models.Model): 52 title = models.CharField(max_length=255) 53 channels = models.ManyToManyField(Channel) 54 55 class Meta: 56 ordering = ('id',) 47 57 48 58 __test__ = {'API_TESTS':""" … … 108 118 >>> management.call_command('loaddata', 'model-inheritance.json', verbosity=0) 109 119 120 ############################################### 121 # Test for ticket #7572 -- MySQL has a problem if the same connection is 122 # used to create tables, load data, and then query over that data. 123 # To compensate, we close the connection after running loaddata. 124 # This ensures that a new connection is opened when test queries are issued. 125 126 >>> management.call_command('loaddata', 'big-fixture.json', verbosity=0) 127 128 >>> articles = Article.objects.exclude(id=9) 129 >>> articles.values_list('id', flat=True) 130 [1, 2, 3, 4, 5, 6, 7, 8] 131 132 # Just for good measure, run the same query again. Under the influence of 133 # ticket #7572, this will give a different result to the previous call. 134 >>> articles.values_list('id', flat=True) 135 [1, 2, 3, 4, 5, 6, 7, 8] 136 110 137 """}
