-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.2.4, 2.4.8
-
Component/s: Sharding
-
None
-
Environment:mongodb 2.2.4
-
Sharding
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
db.collection.find().limit(-1) and db.collection.find().limit(1) is equivalent in mongo 2.4.7,but our mongo being used is 2.2.4.We found that sometimes limit(-1) is different with limit(1) when querying.
in pymongo,the function _getitem_ send a limit of -1 when getting one document:
if isinstance(index, (int, long)):
if index < 0:
raise IndexError("Cursor instances do not support negative"
"indices")
clone = self.clone()
clone.skip(index + self.__skip)
clone.limit(-1) # use a hard limit
for doc in clone:
return doc
raise IndexError("no such item for Cursor instance")
raise TypeError("index %r cannot be applied to Cursor "
"instances" % index)
In large skip,mongo return null,which is expected to return one document. After changing limit(-1) to limit(1),we got correct result. I consider limit(-1) is a bug,or does it exist something i did not realized?
- is related to
-
JAVA-950 Wrong fetching with limit 1 on sharded environment
-
- Closed
-