Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure that ORDER BY clauses from default scopes are not included in …
…total_count queries in AR 3.1.beta1

see: rails/rails#406
  • Loading branch information
amatsuda committed May 9, 2011
1 parent 2dfb555 commit 5de1a97
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/kaminari/models/active_record_relation_methods.rb
Expand Up @@ -13,6 +13,8 @@ def count #:nodoc:
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
Expand Down

0 comments on commit 5de1a97

Please sign in to comment.