Skip to content

skip().limit() do not match behaviour of slice syntax #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ruiwen opened this issue Sep 20, 2013 · 1 comment
Closed

skip().limit() do not match behaviour of slice syntax #474

ruiwen opened this issue Sep 20, 2013 · 1 comment

Comments

@ruiwen
Copy link

ruiwen commented Sep 20, 2013

Using the slice syntax, I get different behaviour from using .skip().limit()

>>> User.objects[1:2]
[<User: 23D2F2DonYwmrjxj7dyVgQ: william cooper>]
>>> User.objects.skip(1).limit(2)
[<User: 23D2F2DonYwmrjxj7dyVgQ: william cooper>, <User: 23D7WmipqKWSsshVVTq7iT: Emma >]

The expected behaviour of the second number in the slice index, eg. [m:n] is to return that number (eg. n) of records, after skipping m items, like the result of the combination of .skip().limit()

@rozza
Copy link
Contributor

rozza commented Sep 27, 2013

Limit is a hard limit where as in slice its the end point so they are different and I think work as expected at the moment.

User.objects[x:y] is the same as from x to y which isnt the same as skip(x) and limit(y) - it is the same as skip(x) limit(x-y)

So this is a won't fix.

@rozza rozza closed this as completed Sep 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants