mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Remove workaround now that total_count allows options passthrough
This commit is contained in:
parent
83b1ff13e3
commit
8e0d22b0da
1 changed files with 3 additions and 9 deletions
|
@ -16,15 +16,9 @@ module Kaminari
|
||||||
# Remove includes only if they are irrelevant
|
# Remove includes only if they are irrelevant
|
||||||
c = c.except(:includes) unless references_eager_loaded_tables?
|
c = c.except(:includes) unless references_eager_loaded_tables?
|
||||||
|
|
||||||
# a workaround to count the actual model instances on distinct query because count + distinct returns wrong value in some cases. see https://github.com/amatsuda/kaminari/pull/160
|
# .group returns an OrderdHash that responds to #count
|
||||||
uses_distinct_sql_statement = c.to_sql =~ /DISTINCT/i
|
c = c.count(column_name, options)
|
||||||
if uses_distinct_sql_statement
|
c.respond_to?(:count) ? c.count(column_name, options) : c
|
||||||
c.length
|
|
||||||
else
|
|
||||||
# .group returns an OrderdHash that responds to #count
|
|
||||||
c = c.count(column_name, options)
|
|
||||||
c.respond_to?(:count) ? c.count(column_name, options) : c
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue