1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #18556 -- Allowed RelatedManager.add() to execute 1 query where possible.

Thanks Loic Bistuer for review.
This commit is contained in:
Tim Graham
2015-03-14 21:25:33 -04:00
committed by Loïc Bistuer
parent c2e70f0265
commit adc0c4fbac
8 changed files with 151 additions and 28 deletions

View File

@@ -115,6 +115,15 @@ class ManyToOneNullTests(TestCase):
self.assertEqual(1, self.r2.article_set.count())
self.assertEqual(1, qs.count())
def test_add_efficiency(self):
r = Reporter.objects.create()
articles = []
for _ in range(3):
articles.append(Article.objects.create())
with self.assertNumQueries(1):
r.article_set.add(*articles)
self.assertEqual(r.article_set.count(), 3)
def test_clear_efficiency(self):
r = Reporter.objects.create()
for _ in range(3):