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
-
|
+
|
|
| 1 | from django.db import models |
| 2 | |
| 3 | class Foo(models.Model): |
| 4 | pass |
| 5 | |
| 6 | |
| 7 | class Bar(models.Model): |
| 8 | bar_foos = models.ManyToManyField(Foo, related_name='+') |
| 9 | |
| 10 | |
| 11 | class Baz(models.Model): |
| 12 | baz_foos = models.ManyToManyField(Foo, related_name='+') |
diff --git a/tests/bug_prefetch_related/tests.py b/tests/bug_prefetch_related/tests.py
new file mode 100644
index 0000000..a1849bf
-
|
+
|
|
| 1 | from django.test import TestCase |
| 2 | |
| 3 | from .models import Bar |
| 4 | |
| 5 | |
| 6 | class 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) |