Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Exclude reorder for count queries.

It turns out reorder behaves differently on Rails 3.1 and requires
explicit exclude to not pollute count query with order clause.
  • Loading branch information...
commit bd00b43d385b6456999524e8c92e7ce601d4d84f 1 parent 4289490
@pawelpacana pawelpacana authored committed
View
2  lib/will_paginate/active_record.rb
@@ -80,7 +80,7 @@ def total_entries
def count
if limit_value
- excluded = [:order, :limit, :offset]
+ excluded = [:order, :limit, :offset, :reorder]
excluded << :includes unless eager_loading?
rel = self.except(*excluded)
# TODO: hack. decide whether to keep
View
5 spec/finders/active_record_spec.rb
@@ -200,6 +200,11 @@
Developer.group(:salary).page(1).total_entries.should == 4
end
+ it "removes :reorder for count with group" do
+ Project.group(:id).reorder(:id).page(1).total_entries
+ $query_sql.last.should_not =~ /\ORDER\b/
+ end
+
it "should not have zero total_pages when the result set is empty" do
Developer.where("1 = 2").page(1).total_pages.should == 1
end
Please sign in to comment.
Something went wrong with that request. Please try again.