[Django] #29559: TransactionTestCase.reset_sequences doesn't reset sequences of auto created ManyToMany models

7 views
Skip to first unread message

Django

unread,
Jul 11, 2018, 4:17:04 AM7/11/18
to django-...@googlegroups.com
#29559: TransactionTestCase.reset_sequences doesn't reset sequences of auto created
ManyToMany models
---------------------------------------------+------------------------
Reporter: Oliver Sauder | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
Consider following example:

{{{
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)

friends = models.ManyToManyField('self')

class AutoIncrementResetTest(TransactionTestCase):
reset_sequences = True

def test_autoincrement_reset1(self):
p = Person.objects.create(first_name='Jack', last_name='Smith')
self.assertEqual(p.pk, 1)

p.friends.add(Person.objects.create(first_name='Jacky',
last_name='Smith'))
self.assertEqual(p.friends.through.objects.first().pk, 1)

def test_autoincrement_reset2(self):
p = Person.objects.create(first_name='Jack', last_name='Smith')
self.assertEqual(p.pk, 1)

p.friends.add(Person.objects.create(first_name='Jacky',
last_name='Smith'))
self.assertEqual(p.friends.through.objects.first().pk, 1)
}}}

Test **test_autoincrement_reset2** will fail with a much higher primary
key, indicating that sequence has not been properly reset. Tested this on
a Postgres database but I assume this error exist on other databases as
well.

--
Ticket URL: <https://code.djangoproject.com/ticket/29559>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 11, 2018, 4:17:37 AM7/11/18
to django-...@googlegroups.com
#29559: TransactionTestCase.reset_sequences doesn't reset sequences of auto created
ManyToMany models
-------------------------------------+-------------------------------------
Reporter: Oliver Sauder | Owner: Oliver
| Sauder
Type: Bug | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Oliver Sauder):

* owner: nobody => Oliver Sauder
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29559#comment:1>

Django

unread,
Jul 11, 2018, 4:24:53 AM7/11/18
to django-...@googlegroups.com
#29559: TransactionTestCase.reset_sequences doesn't reset sequences of auto created
ManyToMany models
-------------------------------------+-------------------------------------
Reporter: Oliver Sauder | Owner: Oliver
| Sauder
Type: Bug | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Oliver Sauder):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/10174 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29559#comment:2>

Django

unread,
Jul 11, 2018, 5:09:02 PM7/11/18
to django-...@googlegroups.com
#29559: TransactionTestCase.reset_sequences doesn't reset sequences of auto created
ManyToMany models
-------------------------------------+-------------------------------------
Reporter: Oliver Sauder | Owner: Oliver
| Sauder
Type: Bug | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29559#comment:3>

Django

unread,
Jul 11, 2018, 9:04:30 PM7/11/18
to django-...@googlegroups.com
#29559: TransactionTestCase.reset_sequences doesn't reset sequences of auto created
ManyToMany models
-------------------------------------+-------------------------------------
Reporter: Oliver Sauder | Owner: Oliver
| Sauder
Type: Bug | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"a07a49ee3295061f384d98d520a565658dd064b8" a07a49ee]:
{{{
#!CommitTicketReference repository=""
revision="a07a49ee3295061f384d98d520a565658dd064b8"
Fixed #29559 -- Fixed TransactionTestCase.reset_sequences for auto-created
m2m through models.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29559#comment:4>

Reply all
Reply to author
Forward
0 new messages