On Tuesday, March 7, 2017 at 9:20:53 AM UTC-5, Richard wrote:
>
> Yes sorry it was more of a complaint than a question
>
> :)
>
> I was disturbed by the fact that I can't leave the limit constant, like 10 
> rows, and only manipulate the offset as I would do in sql...
>

It sounds like you want something like:

LIMIT = 10
offset = request.vars.offset
rows = db(query).select(..., limitby=(LIMIT, offset))

But that isn't really much simpler than the actual DAL API, which is:

rows = db(query).select(..., limitby=(offset, offset + LIMIT))

What is the big difficulty with the above?

I'm not sure why the DAL uses (min, max) rather than (limit, offset), but I 
suspect the reason is that (min, max) is clearer when combining both values 
into a single parameter using a tuple. With a single tuple of values, it is 
natural for the first to be the min and the second the max, but the 
ordering of limit and offset would be somewhat arbitrary and open to 
confusion. If we wanted the API to accept a limit and an offset, it would 
probably be more clear to make those separate arguments.

Anyway, if it really bothers you, you can define a simple function:

def mylim(limit, offset):
    return (offset, offset + limit)

and use:

limitby=mylim(limit, offset)

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to