Ticket #24807: repro-24807.patch

File repro-24807.patch, 1.1 KB (added by Baptiste Mispelon, 9 years ago)

Reproduction testcase

  • new file tests/bug_prefetch_related/models.py

    diff --git a/tests/bug_prefetch_related/__init__.py b/tests/bug_prefetch_related/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/tests/bug_prefetch_related/models.py b/tests/bug_prefetch_related/models.py
    new file mode 100644
    index 0000000..42320a6
    - +  
     1from django.db import models
     2
     3class Foo(models.Model):
     4    pass
     5
     6
     7class Bar(models.Model):
     8    bar_foos = models.ManyToManyField(Foo, related_name='+')
     9
     10
     11class Baz(models.Model):
     12    baz_foos = models.ManyToManyField(Foo, related_name='+')
  • new file tests/bug_prefetch_related/tests.py

    diff --git a/tests/bug_prefetch_related/tests.py b/tests/bug_prefetch_related/tests.py
    new file mode 100644
    index 0000000..a1849bf
    - +  
     1from django.test import TestCase
     2
     3from .models import Bar
     4
     5
     6class ReproTestCase(TestCase):
     7    def setUp(self):
     8        self.bar = Bar.objects.create()
     9
     10    def test_reproduce_issue(self):
     11        queryset = Bar.objects.prefetch_related('bar_foos')
     12   
     13        self.assertQuerysetEqual(queryset, [self.bar.pk], transform=lambda x: x.pk)
Back to Top