mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Merge branch 'master' of https://github.com/denysonique/kaminari into denysonique-master
This commit is contained in:
commit
21462b06e1
1 changed files with 8 additions and 0 deletions
|
@ -12,10 +12,18 @@ module Kaminari
|
|||
# #count overrides the #select which could include generated columns referenced in #order, so skip #order here, where it's irrelevant to the result anyway
|
||||
@total_count ||= begin
|
||||
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?
|
||||
|
||||
uses_distinct_sql_statement = c.to_sql =~ /DISTINCT/i
|
||||
if uses_distinct_sql_statement
|
||||
return c.length
|
||||
end
|
||||
|
||||
# .group returns an OrderdHash that responds to #count
|
||||
c = c.count
|
||||
c.respond_to?(:count) ? c.count : c
|
||||
|
|
Loading…
Add table
Reference in a new issue