mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Ensure that ORDER BY clauses from default scopes are not included in total_count queries in AR 3.1.beta1
see: https://github.com/rails/rails/issues/406
This commit is contained in:
parent
2dfb5553b2
commit
5de1a974f4
1 changed files with 2 additions and 0 deletions
|
@ -13,6 +13,8 @@ module Kaminari
|
|||
def total_count #:nodoc:
|
||||
# #count overrides the #select which could include generated columns referenced in #order, so skip #order here, where it's irrelevant to the result anyway
|
||||
c = except(:offset, :limit, :order)
|
||||
# a workaround for 3.1.beta1 bug. see: https://github.com/rails/rails/issues/406
|
||||
c = c.reorder nil
|
||||
# Remove includes only if they are irrelevant
|
||||
c = c.except(:includes) unless references_eager_loaded_tables?
|
||||
# .group returns an OrderdHash that responds to #count
|
||||
|
|
Loading…
Add table
Reference in a new issue