Merge pull request #1784 from werat/fix_override_comment
Restore comment from cached value after queryset copy
This commit is contained in:
		| @@ -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,12 +2383,17 @@ 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(len(ops), 2) | ||||
|             for op in ops: | ||||
|                 self.assertEqual(op['query']['$query'], {'age': {'$gte': 18}}) | ||||
|                 self.assertEqual(op['query']['$comment'], 'looking for an adult') | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user