hmarr/mongoengine — Issue #342: Slicing returns incorrent result
Author: observerss
Created: 2011-10-28 10:39:23+00:00
State: open

for any document size > 21, e.g. an Entry of size 105

Entry.objects[20:25] returns only the first object

This bug is caused by queryset.py, line around 1612

====================
def __repr__(self):
limit = REPR_OUTPUT_SIZE + 1
if self._limit is not None and self._limit < limit:
limit = self._limit
=======================

after I dive into the problem I found that self._limit does not mean "commonsense" limit

in fact the value of self._limit is skip+limit

so here the code should be (self._limit-self._skip) < limit

I think the variable name would better be renamed, otherwise these kind of bugs will happen randomly when other person misunderstanding this value