datamapper/dm-aggregates — Issue #17: Incorrect query when counting has n, :through relationships.
Author: postmodern
Created: 2012-02-01 21:04:02+00:00
State: open

I've [reproduced](https://github.com/postmodern/dm-bug-report/tree/relationship_count) a bug where dm-aggregates would not generate a `GROUP BY` clause to remove duplicate entries when counting a `has n, :through` relationship, thus resulting in inflated numbers.

git clone https://github.com/postmodern/dm-bug-report.git -b relationship_count
cd dm-bug-report/
bundle install
ruby bug.rb
DEBUG=true ruby bug.rb