I get the following failure when running "nosetests -v --pdb --pdb-failures":
test_uuid_subtype (test.test_collection.TestCollection) ... > /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(487)_baseAssertEqual()
-> raise self.failureException(msg)
(Pdb) where
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(318)run()
-> testMethod()
/InstantGeo/src/mongodb-mongo-python-driver-c59db8c/test/test_collection.py(1399)test_uuid_subtype()
-> self.assertEqual(1, coll.find_one(
)['i'])
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(494)assertEqual()
-> assertion_func(first, second, msg=msg)
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(487)_baseAssertEqual()
-> raise self.failureException(msg)
(Pdb) up
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(494)assertEqual()
-> assertion_func(first, second, msg=msg)
(Pdb) up
> /InstantGeo/src/mongodb-mongo-python-driver-c59db8c/test/test_collection.py(1399)test_uuid_subtype()
-> self.assertEqual(1, coll.find_one(
)['i'])
(Pdb) p uu
UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')
(Pdb) p coll
Collection(Database(Connection('localhost', 27017), u'pymongo_test'), u'uuid')
(Pdb) coll.find_one(
)
{u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}(Pdb) l
1394 coll.insert(
)
1395 self.assertEqual(0, coll.find_one(
)['i'])
1396 doc = coll.find_one(
)
1397 doc['i'] = 1
1398 coll.save(doc)
1399 -> self.assertEqual(1, coll.find_one(
)['i'])
1400
1401 # Test update
1402 coll.uuid_subtype = UUID_SUBTYPE
1403 coll.update(
, {'$set': {'i': 2}})
1404 coll.uuid_subtype = OLD_UUID_SUBTYPE
(Pdb) doc
(Pdb) coll.save(doc)
UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')
(Pdb) coll.find_one(
)
{u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}(Pdb) doc
{u'i': 1, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}The MongoDB log shows:
Mon Nov 21 17:50:19 [conn2979] User Assertion: 11000:E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData }
Mon Nov 21 17:50:19 [conn2979] update pymongo_test.uuid query:
update:
{ _id: BinData, i: 1 } upsert:1 exception: E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData } code:11000 0ms
Mon Nov 21 17:50:19 [journal] lsn set 2920169
Trying an update with upsert=True give the same error:
(Pdb) coll.update(
{ '_id': uu}, doc, True)
(Pdb) coll.find_one(
)
{u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}MongoDB Log:
Mon Nov 21 17:57:24 [conn2979] User Assertion: 11000:E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData }
Mon Nov 21 17:57:24 [conn2979] update pymongo_test.uuid query:
update:
{ _id: BinData, i: 1 }upsert:1 exception: E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData } code:11000 0ms
Trying an update with upsert=False does not give an error but does not update the document:
(Pdb) coll.update(
{ '_id': uu}, doc, False)
(Pdb) coll.find_one(
)
{u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}MongoDB Log:
Mon Nov 21 17:57:38 [conn2979] update pymongo_test.uuid query:
{ _id: BinData }update:
{ _id: BinData, i: 1 }0ms
I am unsure what to make of this.