-
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
total_count gives wrong result after a calling map on an empty AR::Relation instance #845
Comments
@denislins Could you provide an example with a failing test using this bug report template? |
@yuki24 I tried reproducing the bug using the template, but failed. The issue persists on my application though. I'm currently reading the source to better understand the issue. I'll keep you posted. |
@yuki24 I found the difference between my app and the code in the report template. When I make a call to For some reason, it appears that the Also, in both scenarios, if I call My application doesn't use Rails, so I thought maybe my setup is the problem. I see that in the bug report template the gem is loaded using require 'kaminari/core'
require 'kaminari/activerecord' Could this be the issue? |
It seems like you are using the master branch on GitHub in your app. You'd have to change the |
Hey @yuki24, I managed to replicate the bug using the template. You can find it here: https://gist.github.com/denislins/59578a0a9151dedce8a8debd9ff3883f The problem is that I require
When using only I usually require vendor specific gems when available, as it decreases the size and codebase of my dependencies. Which raises the question: should I require |
@denislins Thank you for finding and reporting this! This was obviously a newly introduced bug in the next 1.0.0 release, and it's been fixed via 11d4aaf. |
Sure @amatsuda, happy to help :) I'm still a bit lost, though. How should I proceed with my application? Should I require the gem as a whole, or is there a way to require the 0.17 version of the I tried specifying the version as usual but it didn't work. |
@denislins Sorry for my late reply. As of the version 1.0.0, we've split up the gem into small gems. We used to organize all the files in a single gem ( |
I use 1.1.1 in my rails app, bug still exist, but only when the page is 2 page 1、3、4 run the count sql and get correct total_count page 2 skip the sql, thus total_count is wrong |
@MoonShining please provide example code or a test case that replicates your issue and file a new ticket. |
Hey guys,
I think I've found a very weird bug. It appears that calling
#map
on a activerecord relation instance breaks#total_count
, but only when the relation is empty. I've successfully reproduced it using both PostgreSQL and SQLite in their latest versions.You can get a better vision of the issue in the code below:
The expected result is:
While the actual result is:
I tried searching the issues but didn't find anything related. Please forgive me if this is a known issue, or if it's my fault and therefore not an issue at all.
The text was updated successfully, but these errors were encountered: