hmarr / mongoengine

[Moved to mongoengine/mongoengine]
https://github.com/MongoEngine/mongoengine
MIT License
795 stars 20 forks source link

Slicing returns incorrent result #342

Closed observerss closed 12 years ago

observerss commented 12 years ago

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

observerss commented 12 years ago

I don't know when this bug was introduced, but I think this kind of bugs should be caught by testcases, otherwise we'd better update the testcases.

rozza commented 12 years ago

I think this has been fixed in #341

rozza commented 12 years ago

@observerss please reopen if it wasn't fixed in #341