Commit e58d81e0 by Alex Gaynor

A test for 0 item adds().

parent e364191b
......@@ -132,6 +132,8 @@ class _TaggableManager(models.Manager):
if not isinstance(t, self.through.tag_model())
])
tag_objs = set(tags) - str_tags
# If str_tags has 0 elements Django actually optimizes that to not do a
# query. Malcolm is very smart.
existing = self.through.tag_model().objects.filter(
name__in=str_tags
)
......
......@@ -125,6 +125,8 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
# + 4 queries to create the intermeidary things (including SELECTs, to
# make sure we dont't double create.
self.assert_num_queries(5, pear.tags.add, "green", "delicious")
self.assert_num_queries(0, pear.tags.add)
def test_require_pk(self):
food_instance = self.food_model()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment