Fixed QuerySetNoCache.count() caching (#410)

This commit is contained in:
Ross Lawley
2013-07-30 10:30:16 +00:00
parent 1e4d48d371
commit 6efd6faa3f
4 changed files with 39 additions and 8 deletions

View File

@@ -3483,6 +3483,27 @@ class QuerySetTest(unittest.TestCase):
people.count() # count is cached
self.assertEqual(q, 1)
def test_no_cached_queryset(self):
class Person(Document):
name = StringField()
Person.drop_collection()
for i in xrange(100):
Person(name="No: %s" % i).save()
with query_counter() as q:
self.assertEqual(q, 0)
people = Person.objects.no_cache()
[x for x in people]
self.assertEqual(q, 1)
list(people)
self.assertEqual(q, 2)
people.count()
self.assertEqual(q, 3)
def test_cache_not_cloned(self):
class User(Document):