From 28f66b2783e52d5be51887c31cd2be907b820e11 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sat, 2 Oct 2021 14:43:03 -0400 Subject: [PATCH] Refs #25467 -- Added test for excluding one-to-one relation with unsaved objects. Fixed in 58da81a5a372a69f0bac801c412b57f3cce5f188. --- tests/queries/tests.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 9c1b41a395..ca982b9c6a 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2846,6 +2846,14 @@ class ExcludeTests(TestCase): [self.j1, self.j2], ) + def test_exclude_unsaved_o2o_object(self): + jack = Staff.objects.create(name='jack') + jack_staff = StaffUser.objects.create(staff=jack) + unsaved_object = Staff(name='jane') + + self.assertIsNone(unsaved_object.pk) + self.assertSequenceEqual(StaffUser.objects.exclude(staff=unsaved_object), [jack_staff]) + class ExcludeTest17600(TestCase): """