Merge pull request #1784 from werat/fix_override_comment
Restore comment from cached value after queryset copy
This commit is contained in:
commit
bb22287336
@ -1579,6 +1579,9 @@ class BaseQuerySet(object):
|
||||
if self._batch_size is not None:
|
||||
self._cursor_obj.batch_size(self._batch_size)
|
||||
|
||||
if self._comment is not None:
|
||||
self._cursor_obj.comment(self._comment)
|
||||
|
||||
return self._cursor_obj
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
|
@ -2383,14 +2383,19 @@ class QuerySetTest(unittest.TestCase):
|
||||
age = IntField()
|
||||
|
||||
with db_ops_tracker() as q:
|
||||
adult = (User.objects.filter(age__gte=18)
|
||||
adult1 = (User.objects.filter(age__gte=18)
|
||||
.comment('looking for an adult')
|
||||
.first())
|
||||
|
||||
adult2 = (User.objects.comment('looking for an adult')
|
||||
.filter(age__gte=18)
|
||||
.first())
|
||||
|
||||
ops = q.get_ops()
|
||||
self.assertEqual(len(ops), 1)
|
||||
op = ops[0]
|
||||
self.assertEqual(op['query']['$query'], {'age': {'$gte': 18}})
|
||||
self.assertEqual(op['query']['$comment'], 'looking for an adult')
|
||||
self.assertEqual(len(ops), 2)
|
||||
for op in ops:
|
||||
self.assertEqual(op['query']['$query'], {'age': {'$gte': 18}})
|
||||
self.assertEqual(op['query']['$comment'], 'looking for an adult')
|
||||
|
||||
def test_map_reduce(self):
|
||||
"""Ensure map/reduce is both mapping and reducing.
|
||||
|
Loading…
x
Reference in New Issue
Block a user