DatabaseTestCase should flush constraints #55

Open
ziima opened this Issue Jun 28, 2012 · 2 comments

Projects

None yet

2 participants

ziima commented Jun 28, 2012

Same problem as in https://code.djangoproject.com/ticket/11665. Though I hope it will be fixed soon in here :)

Owner
Almad commented Jun 28, 2012

Is this postgres-specific?

I would not mind having test case, as I don't use postgres nowadays...

ziima commented Jun 28, 2012

This should affect any database with deferred constraints.

Brief test case:

class Parent(models.Model):
    pass

class Child(models.Model):
    parent = models.OneToOneField(Parent, primary_key=True)

class TestCostraints(DatabaseTestCase):
    def test01(self):
        p = Parent(pk=1)
        c = Child(parent=p)
        c.save()
        # This should raise IntegrityError

It actually raises IntergrityError if you use DestructiveDatabaseTestCase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment