diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-07-11 14:22:52 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-07-11 14:22:52 +0000 |
| commit | 52bc78262172ad6e8deb3c75bd65edea68924dbc (patch) | |
| tree | 0a9cae3ec510172e913f47267ef443cba70aa51f /tests/regressiontests | |
| parent | 55968a6edd426af1f341ada1b1b954a607d9c09b (diff) | |
Fixed #11107 -- Corrected the generation of sequence reset SQL for m2m fields with an intermediate model. Thanks to J Clifford Dyer for the report and fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11215 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/m2m_through_regress/fixtures/m2m_through.json | 34 | ||||
| -rw-r--r-- | tests/regressiontests/m2m_through_regress/models.py | 10 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/regressiontests/m2m_through_regress/fixtures/m2m_through.json b/tests/regressiontests/m2m_through_regress/fixtures/m2m_through.json new file mode 100644 index 0000000000..6f24886f02 --- /dev/null +++ b/tests/regressiontests/m2m_through_regress/fixtures/m2m_through.json @@ -0,0 +1,34 @@ +[ + { + "pk": "1", + "model": "m2m_through_regress.person", + "fields": { + "name": "Guido" + } + }, + { + "pk": "1", + "model": "auth.user", + "fields": { + "username": "Guido", + "email": "bdfl@python.org", + "password": "abcde" + } + }, + { + "pk": "1", + "model": "m2m_through_regress.group", + "fields": { + "name": "Python Core Group" + } + }, + { + "pk": "1", + "model": "m2m_through_regress.usermembership", + "fields": { + "user": "1", + "group": "1", + "price": "100" + } + } +]
\ No newline at end of file diff --git a/tests/regressiontests/m2m_through_regress/models.py b/tests/regressiontests/m2m_through_regress/models.py index 8594f19dee..dcf5f8115b 100644 --- a/tests/regressiontests/m2m_through_regress/models.py +++ b/tests/regressiontests/m2m_through_regress/models.py @@ -12,7 +12,9 @@ class Membership(models.Model): def __unicode__(self): return "%s is a member of %s" % (self.person.name, self.group.name) +# using custom id column to test ticket #11107 class UserMembership(models.Model): + id = models.AutoField(db_column='usermembership_id', primary_key=True) user = models.ForeignKey(User) group = models.ForeignKey('Group') price = models.IntegerField(default=100) @@ -196,4 +198,12 @@ doing a join. # Flush the database, just to make sure we can. >>> management.call_command('flush', verbosity=0, interactive=False) +## Regression test for #11107 +Ensure that sequences on m2m_through tables are being created for the through +model, not for a phantom auto-generated m2m table. + +>>> management.call_command('loaddata', 'm2m_through', verbosity=0) +>>> management.call_command('dumpdata', 'm2m_through_regress', format='json') +[{"pk": 1, "model": "m2m_through_regress.usermembership", "fields": {"price": 100, "group": 1, "user": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Guido"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Python Core Group"}}] + """} |
