Ticket #26667: 26667-test.diff

File 26667-test.diff, 1.9 KB (added by Tim Graham, 8 years ago)

A regression test for Django's test suite

  • docs/releases/1.9.7.txt

    diff --git a/docs/releases/1.9.7.txt b/docs/releases/1.9.7.txt
    index 2f55557..0afddcf 100644
    a b Bugfixes  
    2020
    2121* Fixed ``on_commit`` callbacks execution order when callbacks make
    2222  transactions (:ticket:`26627`).
     23
     24* Fixed a regression in queries on a ``OneToOneField`` that has ``to_field``
     25  and ``primary_key=True`` (:ticket:`26667`).
  • tests/one_to_one/models.py

    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):  
    9898    target = models.OneToOneField(Target, models.CASCADE, related_name='hidden+')
    9999
    100100
     101class ToFieldPointer(models.Model):
     102    target = models.OneToOneField(Target, models.CASCADE, to_field='name', primary_key=True)
     103
     104
    101105# Test related objects visibility.
    102106class SchoolManager(models.Manager):
    103107    def get_queryset(self):
  • tests/one_to_one/tests.py

    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  
    66
    77from .models import (
    88    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,
    1111)
    1212
    1313
    class OneToOneTests(TestCase):  
    530530        r = Restaurant.objects.first()
    531531        r2 = Restaurant.objects.filter(pk__exact=r).first()
    532532        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)
Back to Top