Skip to content

Commit

Permalink
Active Record: fix total_entries on grouped relations
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Aug 9, 2011
1 parent f3f9df0 commit 87f827d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/will_paginate/active_record.rb
Expand Up @@ -49,7 +49,9 @@ def total_entries
offset_value + size
else
@total_entries_queried = true
count
result = count
result = result.size if result.respond_to?(:size) and !result.is_a?(Integer)
result
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/finders/active_record_spec.rb
Expand Up @@ -161,6 +161,10 @@

$query_sql.last.should =~ /\bJOIN\b/
end

it "should count with group" do
Developer.group(:salary).page(1).total_entries.should == 4
end
end

it "should not ignore :select parameter when it says DISTINCT" do
Expand Down

0 comments on commit 87f827d

Please sign in to comment.