-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:Nothing special
Here is the unit test (pseudocode).
Class MyClass(object):
"""
Class has _getitem_ and _setitem_ (possibly because it inherits from dict).
"""
pass
cursor = some_collection.find(as_class=MyClass)
for c in cursor:
print type (c) # result is MyClass
cursor = some_collection.find(as_class=MyClass)
c = cursor[0]
print type (c) # result is dict
I believe the problem is in Cursor.clone:
copy = Cursor(self._collection, self.spec, self._fields,
self._skip, self.limit, self._timeout,
self._tailable, self.snapshot, as_class = self._as_class)
When the copy is made (for _getitem_) the as_class property is lost.
find_one() internally does a
for result in self.find(spec_or_id, *args, **kwargs).limit(-1):
so you only see the problem in find() not find_one().