#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.cf058b066b77ae36d95621d995d0612e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to