explicitly remove select condition from AREL when counting #973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For some reason in my app ActiveRecord is not removing the select when executing a count. I know this because PostgreSQL is giving an explicit error message showing that ActiveRecord is trying to do both the count and the custom select.
Explicitly telling ActiveRecord to remove the select fixes my problem.
I have attached a stack trace of the failure in my app. After many hours of trying, I cannot create a test case that elicits this problem in the Kaminari test suite. The differences between my very large app and the Kaminari test app are too great and the specific failing example involves some extremely complex AREL.
Anyhow, would you be willing to add this explicit removal of the select clause when counting? It is always good to remove the select when counting, and apparently we cannot trust ActiveRecord to remove it automatically in every case, even if I can't work out the exact permutation to elicit the bug in ActiveRecord.
Thank you for your consideration!
Eric
kaminari_stack_trace.txt