uriyyo / fastapi-pagination

FastAPI pagination 📖
https://uriyyo-fastapi-pagination.netlify.app/
MIT License
1.1k stars 126 forks source link

Add limit to CursorParams.size field #1119

Closed barsikus007 closed 2 months ago

barsikus007 commented 2 months ago

Resolves #1116

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.11%. Comparing base (245519c) to head (f46b601). Report is 163 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1119 +/- ## ========================================== + Coverage 93.26% 94.11% +0.84% ========================================== Files 35 37 +2 Lines 1040 1275 +235 ========================================== + Hits 970 1200 +230 - Misses 70 75 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

nikelborm commented 2 months ago

Yay! 🎉

marjoleinveenendaal commented 2 months ago

Hi! While I understand the wish, this completely broke multiple parts of our software, as the APIs now send out an HTTPValidationError when requesting more than 100 records at a time (which is perfectly sensible for us). I was not expecting a breaking change in a patch release!

Is there a way we can make this easily overridable? Because from what we can tell we are going to have to write a custom Page to allow for bigger limits. Which seems a bit overkill for such a small setting.

uriyyo commented 2 months ago

@marjoleinveenendaal I'm so sorry to hear that. It's always such a bad situation when I break someone code(

You can customize size using CustomizedPage:

from fastapi_pagination.cursor import CursorPage as BaseCursorPage
from fastapi_pagination.customization import UseParamsFields, CustomizedPage

CursorPage = CustomizedPage[
    BaseCursorPage,
    UseParamsFields(
        size=Query(50, ge=0),
    ),
]
marjoleinveenendaal commented 2 months ago

Thanks! This is less complex than we thought, we will implement it like this!

uriyyo commented 2 months ago

Great, please, let me know if you will have any kind of issues 🙏