Skip to content

Commit

Permalink
Let me see which test envs are going to fail if not adjusting limit
Browse files Browse the repository at this point in the history
because it's not explained in the PR, and I couldn't reproduce the behavior locally #1009
  • Loading branch information
amatsuda committed Jan 21, 2020
1 parent 54b146b commit 62d8012
Showing 1 changed file with 2 additions and 11 deletions.
Expand Up @@ -59,11 +59,11 @@ def load
else
@values[:limit] = limit_value + 1
# FIXME: this could be removed when we're dropping AR 4 support
@arel.limit = __adjusted_limit__(@values[:limit]) if @arel && __adjustable__?(@arel.limit)
@arel.limit = @values[:limit] if @arel && __adjustable__?(@arel.limit)
super
@values[:limit] = limit_value - 1
# FIXME: this could be removed when we're dropping AR 4 support
@arel.limit = __adjusted_limit__(@values[:limit]) if @arel && __adjustable__?(@arel.limit)
@arel.limit = @values[:limit] if @arel && __adjustable__?(@arel.limit)

if @records.any?
@records = @records.dup if (frozen = @records.frozen?)
Expand All @@ -79,15 +79,6 @@ def __adjustable__?(obj)
obj.class == Integer || obj.class == Fixnum || (obj.class == Arel::Nodes::BindParam && obj.respond_to?(:value))
end

def __adjusted_limit__(limit)
case @arel.limit.class
when Integer, Fixnum
limit
when Arel::Nodes::BindParam
Arel::Nodes::BindParam.new(@arel.limit.value.with_cast_value(limit))
end
end

# The page wouldn't be the last page if there's "limit + 1" record
def last_page?
!out_of_range? && !@_has_next
Expand Down

0 comments on commit 62d8012

Please sign in to comment.