diff --git a/docs/releases/1.9.7.txt b/docs/releases/1.9.7.txt
index 2f55557..0afddcf 100644
a
|
b
|
Bugfixes
|
20 | 20 | |
21 | 21 | * Fixed ``on_commit`` callbacks execution order when callbacks make |
22 | 22 | transactions (:ticket:`26627`). |
| 23 | |
| 24 | * Fixed a regression in queries on a ``OneToOneField`` that has ``to_field`` |
| 25 | and ``primary_key=True`` (:ticket:`26667`). |
diff --git a/tests/one_to_one/models.py b/tests/one_to_one/models.py
index 2742fb1..bd2e5e2 100644
a
|
b
|
class HiddenPointer(models.Model):
|
98 | 98 | target = models.OneToOneField(Target, models.CASCADE, related_name='hidden+') |
99 | 99 | |
100 | 100 | |
| 101 | class ToFieldPointer(models.Model): |
| 102 | target = models.OneToOneField(Target, models.CASCADE, to_field='name', primary_key=True) |
| 103 | |
| 104 | |
101 | 105 | # Test related objects visibility. |
102 | 106 | class SchoolManager(models.Manager): |
103 | 107 | def get_queryset(self): |
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py
index 7e8c9c5..6e524ec 100644
a
|
b
|
from django.utils.deprecation import RemovedInDjango20Warning
|
6 | 6 | |
7 | 7 | from .models import ( |
8 | 8 | Bar, Director, Favorites, HiddenPointer, ManualPrimaryKey, MultiModel, |
9 | | Place, Pointer, RelatedModel, Restaurant, School, Target, UndergroundBar, |
10 | | Waiter, |
| 9 | Place, Pointer, RelatedModel, Restaurant, School, Target, ToFieldPointer, |
| 10 | UndergroundBar, Waiter, |
11 | 11 | ) |
12 | 12 | |
13 | 13 | |
… |
… |
class OneToOneTests(TestCase):
|
530 | 530 | r = Restaurant.objects.first() |
531 | 531 | r2 = Restaurant.objects.filter(pk__exact=r).first() |
532 | 532 | self.assertEqual(r, r2) |
| 533 | |
| 534 | def test_primary_key_to_field_filter(self): |
| 535 | target = Target.objects.create() |
| 536 | pointer = ToFieldPointer.objects.create(target=target) |
| 537 | self.assertQuerysetEqual(ToFieldPointer.objects.filter(target=target), [pointer], lambda x: x) |