cunybpl / aiodal

async data access layer and related tools for sqlalchemy core
0 stars 0 forks source link

fixed limit repeating in paginator #24

Closed tinnaing347 closed 9 months ago

tinnaing347 commented 9 months ago

closes

tinnaing347 commented 9 months ago

the fix is to add the following in _default_paginator:

if "offset" not in request_url:
    # starts here
    if "?" in request_url:
        off_lim = (
            f"&offset={offset+limit}"
            if "limit" in request_url
            else f"&offset={offset+limit}&limit={limit}"
        )
    else:
        off_lim = (
            f"?offset={offset+limit}"
            if "limit" in request_url
            else f"?offset={offset+limit}&limit={limit}"
        )

if limit is present in request_url, only replace the current offset with offset+limit and use the limit comes in as params from url as it is...else add limit as usual..