diff --git a/mongoengine/document.py b/mongoengine/document.py index ae5f585d..2e3eee9d 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -166,7 +166,7 @@ class Document(BaseDocument): @classmethod def _get_collection(cls): """Returns the collection for the document.""" - #TODO: use new get_collection() with PyMongo3 ? + # TODO: use new get_collection() with PyMongo3 ? if not hasattr(cls, '_collection') or cls._collection is None: db = cls._get_db() collection_name = cls._get_collection_name() @@ -308,7 +308,9 @@ class Document(BaseDocument): object_id = collection.insert(doc, **write_concern) else: object_id = collection.save(doc, **write_concern) - # Pymongo 3.0 bug, fix scheduled for 3.0.1 + # TODO: Pymongo 3.0 bug, fix scheduled for 3.0.1 + # In PyMongo 3.0, the save() call calls internally the _update() call + # but they forget to return the _id value passed back, therefore getting it back here if not object_id and pymongo.version_tuple == (3, 0): object_id = self._qs.filter(**self._object_key).first() and \ self._qs.filter(**self._object_key).first().pk diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index 2e087e10..803374bd 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -930,6 +930,7 @@ class BaseQuerySet(object): plan = pprint.pformat(plan) return plan + # DEPRECATED. Has no more impact on PyMongo 3+ def snapshot(self, enabled): """Enable or disable snapshot mode when querying. @@ -1419,7 +1420,8 @@ class BaseQuerySet(object): cursor_args['slave_okay'] = self._slave_okay else: fields_name = 'projection' - # snapshot seems not to be handled at all by PyMongo 3+ + # snapshot is not to handled at all by PyMongo 3+ + # TODO: raise a warning? cursor_args = { 'no_cursor_timeout': self._timeout } diff --git a/tests/fields/fields.py b/tests/fields/fields.py index 3b860cc7..0dc239c4 100644 --- a/tests/fields/fields.py +++ b/tests/fields/fields.py @@ -2491,7 +2491,8 @@ class FieldTest(unittest.TestCase): binary_id = uuid.uuid4().bytes att = Attachment(id=binary_id).save() self.assertEqual(1, Attachment.objects.count()) - self.assertNotEqual(None, Attachment.objects.filter(id=binary_id).first()) + # TODO use assertIsNotNone once Python 2.6 support is dropped + self.assertFalse(Attachment.objects.filter(id=binary_id).first() is not None) att.delete() self.assertEqual(0, Attachment.objects.count())