mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #18556 -- Allowed RelatedManager.add() to execute 1 query where possible.
Thanks Loic Bistuer for review.
This commit is contained in:
parent
c2e70f0265
commit
adc0c4fbac
8 changed files with 151 additions and 28 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue