-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Negative padding returns 0 objects if number of objects is less than negative padding value #839
Comments
@yo-gen Thank you, but I'm wondering what actually does a negative padding mean. |
Yes. We use it in our app. Our requirement is to fetch 5 videos in the first call. And in subsequent page calls we want 10 videos to be fetched. |
@yo-gen Well, we are asking because we want to understand why you have that requirement. From a user's perspective, it's extremely weird to see a smaller number of elements only on the first page. Also, please format your comment properly. I personally consider unformatted comments to be a rude attitude. |
@yuki24 I am sorry. I had no intentions of being rude. I am a Github starter and haven't ever used it actively. So, please tell me the problems with my formatting of the comments and I'll take care henceforth. Thanks. |
@yo-gen I've formatted your comments above. You can use GitHub Flavored Markdown almost anywhere on GitHub so others can easily read comments. Speaking of your requirement, it sounds more like a performance issue, and you are just trying to work around it, and I'm not sure if we should change kaminari just for your edge case. |
@yuki24 Alright. We had already implemented our case by calling However I thought this was some small bug in Kaminari as it returned correct value with negative_padding if |
I'm not strongly against the proposed behavior, but there exists a problem regarding negative padding. I investigated this issue a little bit, and found that negative padding with the Array extension is completely broken. It actually returns such a funny result: Kaminari.paginate_array([*1..10]).page(1).per(5).padding(-2)
#=> [9, 10] OTOH passing a negative number to
Based on this fact, I'm leaning towards rejecting negative padding, unless @yo-gen or anyone else submits a patch that nicely fixes the inconsistency between these adapters and Array. |
Just upgraded kaminari and this breaks our functionality of giving a negative offset when we delete an item from the list. |
@cthorner could you file a new issue with a use case where a negative offset is helpful? According to the conversation above, negative offsets could cause more trouble than being helpful. |
For eg. if I have 3 objects in array.
Then,
Kaminari.paginate_array(my_array).page(1).per(10).padding(-5)
returns count as 0, and 0 objects in the result.
It should return back count as 3 and results as
[1,2,3]
I am using
kaminari-0.17.0
rails 4.2.7.1
ruby-2.3.1
The text was updated successfully, but these errors were encountered: