Skip to content
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

Fix bug with optional params and page creation #608

Merged
merged 1 commit into from
Apr 9, 2023

Conversation

uriyyo
Copy link
Owner

@uriyyo uriyyo commented Apr 9, 2023

No description provided.

@uriyyo uriyyo added the bug Something isn't working label Apr 9, 2023
@uriyyo uriyyo self-assigned this Apr 9, 2023
@uriyyo uriyyo merged commit 4620c20 into main Apr 9, 2023
@uriyyo uriyyo deleted the bugfix/optional-params branch April 9, 2023 10:02
@@ -59,13 +59,15 @@ def create(
if not isinstance(params, Params):
raise ValueError("Page should be used with Params")

pages = ceil(total / params.size) if total is not None else None
size = params.size if params.size is not None else total
page = params.page if params.page is not None else 1
Copy link
Contributor

@s-rigaud s-rigaud Apr 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uriyyo
Isn't page = params.page or 1 better in this case ? As page 0 should not be accepted
Same for size ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-rigaud Thanks for your suggestion.

We can have custom params that can use zero-based pagination. page = params.page or 1 can produce bugs, cause we never now how end-user customization will look like.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I understand, thanks for the response 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants