1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #26706, Refs #34633 -- Added test for prefetch_related() cache invalidation in ManyRelatedManager.create().

This commit is contained in:
Mariusz Felisiak 2023-06-06 07:33:59 +02:00 committed by GitHub
parent 51fdea6841
commit 40a2c811e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -512,6 +512,12 @@ class ManyToManyTests(TestCase):
a4.publications.add(self.p1)
self.assertEqual(a4.publications.count(), 2)
def test_create_after_prefetch(self):
a4 = Article.objects.prefetch_related("publications").get(id=self.a4.id)
self.assertSequenceEqual(a4.publications.all(), [self.p2])
p5 = a4.publications.create(title="Django beats")
self.assertCountEqual(a4.publications.all(), [self.p2, p5])
def test_set_after_prefetch(self):
a4 = Article.objects.prefetch_related("publications").get(id=self.a4.id)
self.assertEqual(a4.publications.count(), 1)