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:
parent
51fdea6841
commit
40a2c811e3
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user