Merge commit '18baa2dd7a'
This commit is contained in:
commit
378b52321b
2 changed files with 23 additions and 0 deletions
|
|
@ -434,6 +434,12 @@ class QuerySet(object):
|
|||
if self._document._meta['ordering']:
|
||||
self.order_by(*self._document._meta['ordering'])
|
||||
|
||||
if self._limit is not None:
|
||||
self._cursor_obj.limit(self._limit)
|
||||
|
||||
if self._skip is not None:
|
||||
self._cursor_obj.skip(self._skip)
|
||||
|
||||
return self._cursor_obj
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -1429,6 +1429,23 @@ class QuerySetTest(unittest.TestCase):
|
|||
|
||||
Post.drop_collection()
|
||||
|
||||
def test_call_after_limits_set(self):
|
||||
"""Ensure that re-filtering after slicing works
|
||||
"""
|
||||
class Post(Document):
|
||||
title = StringField()
|
||||
|
||||
Post.drop_collection()
|
||||
|
||||
post1 = Post(title="Post 1")
|
||||
post1.save()
|
||||
post2 = Post(title="Post 2")
|
||||
post2.save()
|
||||
|
||||
posts = Post.objects.all()[0:1]
|
||||
self.assertEqual(len(list(posts())), 1)
|
||||
|
||||
Post.drop_collection()
|
||||
|
||||
class QTest(unittest.TestCase):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue