Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/benmur/mongoengine into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Oct 20, 2010
2 parents 3b88a4f + 18baa2d commit e868f37
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mongoengine/queryset.py
Expand Up @@ -434,6 +434,12 @@ def _cursor(self):
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
Expand Down
17 changes: 17 additions & 0 deletions tests/queryset.py
Expand Up @@ -1377,6 +1377,23 @@ class Post(Document):

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):

Expand Down

0 comments on commit e868f37

Please sign in to comment.