Skip to content

Conversation

@allomov
Copy link

@allomov allomov commented Jul 19, 2023

It has been observed that using active record .merge can result in having .limit_value as nil. This can cause .total_entries and .total_pages to fail with the error comparison of Integer with nil failed on the following line:

if loaded? and size < limit_value and (current_page == 1 or size > 0)

Here is an example that demonstrates how you can get a nil value in the limit_value field:

User.limit(10).limit_value
# => 10
User.joins(:role).limit(10).merge(Role.all.unscope(:limit)).limit_value
# => nil

There are two places that require updates:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant