datamapper / dm-aggregates

DataMapper plugin providing support for aggregates on collections
http://datamapper.org/
MIT License
16 stars 15 forks source link

Removed offset parameter from #count #14

Closed alexgb closed 11 years ago

alexgb commented 13 years ago

This helps when doing paging like so...

collection = Person.all(:age.gt => 30, :limit => 25, :offset => 50)
return {:results => collection, :total => collection.count}.to_json

Also, in this regard, my preference is for limit to be ignored from count aggregations and have added a spec to indicate so.

dkubb commented 11 years ago

The intention for #count is that it apply to the collection as it is at that point in time. For example, these two should always be equivalent:

collection.count == collection.to_a.count

The fact that the COUNT(*) is applied to the query directly, and not using the query as a subquery, is the reason for the behaviour being broken at the moment.