aarondfrancis / fast-paginate

A fast implementation of offset/limit pagination for Laravel.
MIT License
1.21k stars 56 forks source link

Prevent query when the keys are empty #54

Closed hungthai1401 closed 5 months ago

hungthai1401 commented 1 year ago

Dear @aarondfrancis ,

I have a query with the fast pagination that do the follow sql:

select count(*) as aggregate from `users`;
select `users`.`id` from `users` limit 2 offset 30;
select * from `users` where 0 = 1 limit 3 offset 0;

I think the last query of fast paginations is redundant because the keys from the second query result is empty. Expected:

select count(*) as aggregate from `users`;
select `users`.`id` from `users` limit 2 offset 30;

I have created this PR to prevent it.

aarondfrancis commented 5 months ago

Amazing, thank you so much!