diff options
author | Tim Graham <timograham@gmail.com> | 2015-03-14 21:25:33 -0400 |
---|---|---|
committer | Loïc Bistuer <loic.bistuer@gmail.com> | 2015-07-28 09:28:25 +0700 |
commit | adc0c4fbac98f9cb975e8fa8220323b2de638b46 (patch) | |
tree | 6d00b444423b09a764fa3eb7d5b9f278c6531c0e /tests/many_to_one_null | |
parent | c2e70f02653519db3a49cd48f5158ccad7434d25 (diff) | |
download | django-adc0c4fbac98f9cb975e8fa8220323b2de638b46.tar.gz |
Fixed #18556 -- Allowed RelatedManager.add() to execute 1 query where possible.
Thanks Loic Bistuer for review.
Diffstat (limited to 'tests/many_to_one_null')
-rw-r--r-- | tests/many_to_one_null/tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/many_to_one_null/tests.py b/tests/many_to_one_null/tests.py index e39f527abe..06f756e35b 100644 --- a/tests/many_to_one_null/tests.py +++ b/tests/many_to_one_null/tests.py @@ -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): |