diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-07-23 05:04:06 -0700 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-27 12:04:56 +0200 |
commit | 4122d9d3f1983eea612f236e941d937bd8589a0d (patch) | |
tree | 8b13542116159590bc5fab124574e6b8038de814 /tests/many_to_one | |
parent | 619c9a4f49a1f0d9b53a732ae8c5132e32a6ce1c (diff) | |
download | django-4122d9d3f1983eea612f236e941d937bd8589a0d.tar.gz |
Refs #28147 -- Fixed setting of OneToOne and Foreign Key fields to None when using attnames.
Regression in 519016e5f25d7c0a040015724f9920581551cab0.
Diffstat (limited to 'tests/many_to_one')
-rw-r--r-- | tests/many_to_one/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py index a5215e58d7..e3121a7701 100644 --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -168,6 +168,18 @@ class ManyToOneTests(TestCase): parent.bestchild_id = child2.pk self.assertTrue(Parent.bestchild.is_cached(parent)) + def test_assign_fk_id_none(self): + parent = Parent.objects.create(name='jeff') + child = Child.objects.create(name='frank', parent=parent) + parent.bestchild = child + parent.save() + parent.bestchild_id = None + parent.save() + self.assertIsNone(parent.bestchild_id) + self.assertFalse(Parent.bestchild.is_cached(parent)) + self.assertIsNone(parent.bestchild) + self.assertTrue(Parent.bestchild.is_cached(parent)) + def test_selects(self): self.r.article_set.create(headline="John's second story", pub_date=datetime.date(2005, 7, 29)) self.r2.article_set.create(headline="Paul's story", pub_date=datetime.date(2006, 1, 17)) |