Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes in 0.10.1 - DEV
=======================
- Fix infinite recursion with CASCADE delete rules under specific conditions. #1046
- Fix CachedReferenceField bug when loading cached docs as DBRef but failing to save them. #1047
- Fix ignored chained options #842

Changes in 0.10.0
=================
Expand Down
8 changes: 1 addition & 7 deletions mongoengine/queryset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,7 @@ def limit(self, n):
:param n: the maximum number of objects to return
"""
queryset = self.clone()
if n == 0:
queryset._cursor.limit(1)
else:
queryset._cursor.limit(n)
queryset._limit = n
queryset._limit = n if n != 0 else 1
# Return self to allow chaining
return queryset

Expand All @@ -699,7 +695,6 @@ def skip(self, n):
:param n: the number of objects to skip before returning results
"""
queryset = self.clone()
queryset._cursor.skip(n)
queryset._skip = n
return queryset

Expand All @@ -717,7 +712,6 @@ def hint(self, index=None):
.. versionadded:: 0.5
"""
queryset = self.clone()
queryset._cursor.hint(index)
queryset._hint = index
return queryset

Expand Down
4 changes: 2 additions & 2 deletions tests/document/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ class BlogPost(Document):
self.assertEqual(BlogPost.objects.hint('tags').count(), 10)
else:
def invalid_index():
BlogPost.objects.hint('tags')
BlogPost.objects.hint('tags').next()
self.assertRaises(TypeError, invalid_index)

def invalid_index_2():
return BlogPost.objects.hint(('tags', 1))
return BlogPost.objects.hint(('tags', 1)).next()
self.assertRaises(Exception, invalid_index_2)

def test_unique(self):
Expand Down
4 changes: 4 additions & 0 deletions tests/queryset/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ def test_find(self):
"[<Person: Person object>, <Person: Person object>]", "%s" % self.Person.objects[1:3])
self.assertEqual(
"[<Person: Person object>, <Person: Person object>]", "%s" % self.Person.objects[51:53])
# Test only after limit
self.assertEqual(self.Person.objects().limit(2).only('name')[0].age, None)
# Test only after skip
self.assertEqual(self.Person.objects().skip(2).only('name')[0].age, None)

def test_find_one(self):
"""Ensure that a query using find_one returns a valid result.
Expand Down