Merge pull request #1049 from DavidBord/fix-842
fix-#842: Fix ignored chained options
This commit is contained in:
commit
9671ca5ebf
@ -6,6 +6,7 @@ Changes in 0.10.1 - DEV
|
|||||||
=======================
|
=======================
|
||||||
- Fix infinite recursion with CASCADE delete rules under specific conditions. #1046
|
- 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 CachedReferenceField bug when loading cached docs as DBRef but failing to save them. #1047
|
||||||
|
- Fix ignored chained options #842
|
||||||
|
|
||||||
Changes in 0.10.0
|
Changes in 0.10.0
|
||||||
=================
|
=================
|
||||||
|
@ -684,11 +684,7 @@ class BaseQuerySet(object):
|
|||||||
:param n: the maximum number of objects to return
|
:param n: the maximum number of objects to return
|
||||||
"""
|
"""
|
||||||
queryset = self.clone()
|
queryset = self.clone()
|
||||||
if n == 0:
|
queryset._limit = n if n != 0 else 1
|
||||||
queryset._cursor.limit(1)
|
|
||||||
else:
|
|
||||||
queryset._cursor.limit(n)
|
|
||||||
queryset._limit = n
|
|
||||||
# Return self to allow chaining
|
# Return self to allow chaining
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
@ -699,7 +695,6 @@ class BaseQuerySet(object):
|
|||||||
:param n: the number of objects to skip before returning results
|
:param n: the number of objects to skip before returning results
|
||||||
"""
|
"""
|
||||||
queryset = self.clone()
|
queryset = self.clone()
|
||||||
queryset._cursor.skip(n)
|
|
||||||
queryset._skip = n
|
queryset._skip = n
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
@ -717,7 +712,6 @@ class BaseQuerySet(object):
|
|||||||
.. versionadded:: 0.5
|
.. versionadded:: 0.5
|
||||||
"""
|
"""
|
||||||
queryset = self.clone()
|
queryset = self.clone()
|
||||||
queryset._cursor.hint(index)
|
|
||||||
queryset._hint = index
|
queryset._hint = index
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
@ -577,11 +577,11 @@ class IndexesTest(unittest.TestCase):
|
|||||||
self.assertEqual(BlogPost.objects.hint('tags').count(), 10)
|
self.assertEqual(BlogPost.objects.hint('tags').count(), 10)
|
||||||
else:
|
else:
|
||||||
def invalid_index():
|
def invalid_index():
|
||||||
BlogPost.objects.hint('tags')
|
BlogPost.objects.hint('tags').next()
|
||||||
self.assertRaises(TypeError, invalid_index)
|
self.assertRaises(TypeError, invalid_index)
|
||||||
|
|
||||||
def invalid_index_2():
|
def invalid_index_2():
|
||||||
return BlogPost.objects.hint(('tags', 1))
|
return BlogPost.objects.hint(('tags', 1)).next()
|
||||||
self.assertRaises(Exception, invalid_index_2)
|
self.assertRaises(Exception, invalid_index_2)
|
||||||
|
|
||||||
def test_unique(self):
|
def test_unique(self):
|
||||||
|
@ -188,6 +188,10 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
"[<Person: Person object>, <Person: Person object>]", "%s" % self.Person.objects[1:3])
|
"[<Person: Person object>, <Person: Person object>]", "%s" % self.Person.objects[1:3])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
"[<Person: Person object>, <Person: Person object>]", "%s" % self.Person.objects[51:53])
|
"[<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):
|
def test_find_one(self):
|
||||||
"""Ensure that a query using find_one returns a valid result.
|
"""Ensure that a query using find_one returns a valid result.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user