Closed walro closed 2 years ago
@yunanhelmy Do you have any idea on this? Because what @walro mention here make sense that if we don't return in ActiveRecord::Relation, it will be less useful
@walro Thank you for pointing out.
@Uysim That was because the return is items[0..pagy.items-1]
, so it will become array. I will create PR to change the return not as array, but as ActiveRecord::Relation.
@walro @Uysim https://github.com/Uysim/pagy-cursor/pull/30 please let me know your feedback.
@yunanhelmy I think the better solution here is to revert #19
@walro and @yunanhelmy We have it fix at version 0.2.2
Hiya, I was upgrading to 0.2.1 from 0.2.0 and noticed that the return value of
pagy_cursor
changed from aActiveRecord::Relation
to a plain oldArray
. I tracked down the behavior change to #19 (diff link) where the subscript operator causes the query to be "eagerly" evaluated.The following test case passes on 0.2.0 but not on 0.2.1:
This was a bit surprising to us (or our code-base at least) and to me it seems like it might have made the gem a bit less useful as you might not always want your records loaded just yet. I understand the change in #19 was a good one, but maybe there is a way to still support the old "chainable relation" return type?