mirror of
https://github.com/django/django.git
synced 2025-11-25 13:13:28 +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
1 changed files with 6 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue