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

Make negetive page[size] exception safe #62

Merged
merged 3 commits into from
May 13, 2022
Merged

Make negetive page[size] exception safe #62

merged 3 commits into from
May 13, 2022

Conversation

ifduyue
Copy link
Contributor

@ifduyue ifduyue commented May 11, 2022

If page[size] is negative, QueryException will be raised saying

"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0' at line 1 (SQL: select * from products offset 0)"

This change fixes this by quietly setting page size to $defaultSize when it is negative. This is also the behavior when page number is negative.

ifduyue and others added 2 commits May 11, 2022 23:49
If `page[size]` is negative, QueryException will be raised saying

> "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0' at line 1 (SQL: select * from `products` offset 0)"

This change fixes this by quietly setting page size to `$defaultSize` when it is negative. This is also the behavior when page number is negative.
@freekmurze
Copy link
Member

Could you add a test that covers this new logic?

@ifduyue
Copy link
Contributor Author

ifduyue commented May 12, 2022

Could you add a test that covers this new logic?

Sure, I'll add tests.

@ifduyue
Copy link
Contributor Author

ifduyue commented May 12, 2022

@freekmurze Tests added.

@freekmurze freekmurze merged commit 46260ad into spatie:main May 13, 2022
@freekmurze
Copy link
Member

Thanks!

@ifduyue ifduyue deleted the patch-1 branch May 13, 2022 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants