comments update after having tested PyMongo 3.0.1
This commit is contained in:
parent
3ab5ba6149
commit
c5ed308ea5
@ -308,9 +308,9 @@ class Document(BaseDocument):
|
|||||||
object_id = collection.insert(doc, **write_concern)
|
object_id = collection.insert(doc, **write_concern)
|
||||||
else:
|
else:
|
||||||
object_id = collection.save(doc, **write_concern)
|
object_id = collection.save(doc, **write_concern)
|
||||||
# TODO: Pymongo 3.0 bug, fix scheduled for 3.0.1
|
|
||||||
# In PyMongo 3.0, the save() call calls internally the _update() call
|
# 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
|
# but they forget to return the _id value passed back, therefore getting it back here
|
||||||
|
# Correct behaviour in 2.X and in 3.0.1+ versions
|
||||||
if not object_id and pymongo.version_tuple == (3, 0):
|
if not object_id and pymongo.version_tuple == (3, 0):
|
||||||
pk_as_mongo_obj = self._fields.get(self._meta['id_field']).to_mongo(self.pk)
|
pk_as_mongo_obj = self._fields.get(self._meta['id_field']).to_mongo(self.pk)
|
||||||
object_id = self._qs.filter(pk=pk_as_mongo_obj).first() and \
|
object_id = self._qs.filter(pk=pk_as_mongo_obj).first() and \
|
||||||
|
@ -513,7 +513,7 @@ class IndexesTest(unittest.TestCase):
|
|||||||
self.assertEqual(BlogPost.objects.count(), 10)
|
self.assertEqual(BlogPost.objects.count(), 10)
|
||||||
self.assertEqual(BlogPost.objects.hint().count(), 10)
|
self.assertEqual(BlogPost.objects.hint().count(), 10)
|
||||||
|
|
||||||
# PyMongo 3.0 bug
|
# PyMongo 3.0 bug only, works correctly with 2.X and 3.0.1+ versions
|
||||||
if pymongo.version != '3.0':
|
if pymongo.version != '3.0':
|
||||||
self.assertEqual(BlogPost.objects.hint([('tags', 1)]).count(), 10)
|
self.assertEqual(BlogPost.objects.hint([('tags', 1)]).count(), 10)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user