fix-#1187: count on ListField of EmbeddedDocumentField fails
This commit is contained in:
		| @@ -7,6 +7,7 @@ Changes in 0.10.6 - Dev | |||||||
| - Add support for mocking MongoEngine based on mongomock. #1151 | - Add support for mocking MongoEngine based on mongomock. #1151 | ||||||
| - Fixed not being able to run tests on Windows. #1153 | - Fixed not being able to run tests on Windows. #1153 | ||||||
| - Allow creation of sparse compound indexes. #1114 | - Allow creation of sparse compound indexes. #1114 | ||||||
|  | - count on ListField of EmbeddedDocumentField fails. #1187 | ||||||
|  |  | ||||||
| Changes in 0.10.5 | Changes in 0.10.5 | ||||||
| ================= | ================= | ||||||
|   | |||||||
| @@ -697,7 +697,7 @@ class ListField(ComplexBaseField): | |||||||
|  |  | ||||||
|     def prepare_query_value(self, op, value): |     def prepare_query_value(self, op, value): | ||||||
|         if self.field: |         if self.field: | ||||||
|             if op in ('set', 'unset') and ( |             if op in ('set', 'unset', None) and ( | ||||||
|                     not isinstance(value, basestring) and |                     not isinstance(value, basestring) and | ||||||
|                     not isinstance(value, BaseDocument) and |                     not isinstance(value, BaseDocument) and | ||||||
|                     hasattr(value, '__iter__')): |                     hasattr(value, '__iter__')): | ||||||
|   | |||||||
| @@ -3613,6 +3613,15 @@ class QuerySetTest(unittest.TestCase): | |||||||
|         self.assertEqual(MyDoc.objects.count(), 10) |         self.assertEqual(MyDoc.objects.count(), 10) | ||||||
|         self.assertEqual(MyDoc.objects.none().count(), 0) |         self.assertEqual(MyDoc.objects.none().count(), 0) | ||||||
|  |  | ||||||
|  |     def test_count_list_embedded(self): | ||||||
|  |         class B(EmbeddedDocument): | ||||||
|  |             c = StringField() | ||||||
|  |  | ||||||
|  |         class A(Document): | ||||||
|  |             b = ListField(EmbeddedDocumentField(B)) | ||||||
|  |  | ||||||
|  |         self.assertEqual(A.objects(b=[{'c': 'c'}]).count(), 0) | ||||||
|  |  | ||||||
|     def test_call_after_limits_set(self): |     def test_call_after_limits_set(self): | ||||||
|         """Ensure that re-filtering after slicing works |         """Ensure that re-filtering after slicing works | ||||||
|         """ |         """ | ||||||
| @@ -4888,5 +4897,6 @@ class QuerySetTest(unittest.TestCase): | |||||||
|  |  | ||||||
|         self.assertEqual(1, Doc.objects(item__type__="axe").count()) |         self.assertEqual(1, Doc.objects(item__type__="axe").count()) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user