fast-paginate icon indicating copy to clipboard operation
fast-paginate copied to clipboard

perPage -1 will give zero (0) result instead of all result

Open sawirricardo opened this issue 1 year ago • 1 comments

before, using paginate(-1) will give you "all" results.

But it seems fastPaginate(-1) gives us zero results.

The issue maybe because of fastPaginate under the hood uses simplePaginate(), which also returns 0 with if supplied with per page -1

standar query image

fast paginate query image

sawirricardo avatar Sep 22 '22 12:09 sawirricardo

Interesting! I didn't know that about -1, I'll add a test for that and fix it. Thanks!

aarondfrancis avatar Sep 22 '22 15:09 aarondfrancis

Yeah, it's a trick if you want to show all the records without making additional count query. though after further investigation, it seems to be the simplePagination issue?

sawirricardo avatar Sep 26 '22 08:09 sawirricardo

this using is really interesting, so what is the advantage or disadvantage of this using?

ustabasiibrahim avatar Sep 28 '22 12:09 ustabasiibrahim

Landed here looking for how to get all records without limit. Any advice? I'm using 99999 value but it looks like a horrible hack.

lucianobosco avatar Oct 30 '22 19:10 lucianobosco

I can't figure out how this is supposed to work. Doing User::paginate(-1) throws an error for me on MySQL. What database are y'all using? Either way, I added a check to see if the page is -1 and if it is it will defer to the Laravel methods.

https://github.com/hammerstonedev/fast-paginate/commit/e0dc0839d90e17d16ae93375cbebd9dbfccb16f7

aarondfrancis avatar Apr 28 '23 22:04 aarondfrancis