-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:pymongo 1.6, MongoDB 1.4.3. Single server, Ubuntu 9.10.
-
ALL
I had a case where I wanted to compare ObjectId instances as part of a map_reduce and it was failing because checking for equality on two ObjectId instances that should have been the same aren't detected as being the same.
Sample Python program (showing nothing was emit()'ed from map function, even though there should have been:
import pymongo
MAP = """
function() {
for (i=0; i < this.all.length; i++) {
if (this.single == this.all[i])
}
}"""
RED = "function(k,v)
"
dbc=pymongo.Connection(); db=dbc.test
oids = []
c1 = db.entries_with_ids
c1.remove()
oids.append(c1.save(
))
oids.append(c1.save(
))
c2 = db.mr_test
c2.remove()
c2.save(
)
c3 = c2.map_reduce(pymongo.code.Code(MAP), pymongo.code.Code(RED))
print c2.find_one()
print 'result size',c3.count()
Sample output:
{u'single': ObjectId('4c1a478603eba73620000000'), u'_id': ObjectId('4c1a478603eba73620000002'), u'all': [ObjectId('4c1a478603eba73620000000'), ObjectId('4c1a478603eba73620000001')]}result size 0