alecdotninja / active_record_distinct_on

Support for `DISTINCT ON` statements when querying with ActiveRecord
MIT License
34 stars 11 forks source link

Support count queries with joins #23

Closed machty closed 1 year ago

machty commented 1 year ago

In our app, we have more complex scopes with joins + distinct_on that cause something like the following error when you call .count on it. This PR fixes this, and also runs against actual Postgres rather than SQLite to more proactively surface issues like these in the future.

ERROR:  column \"customers.id\" must appear in the GROUP BY clause or be used in an aggregate function
alecdotninja commented 1 year ago

Thank you for looking into this and adding tests! I will review this shortly and cut a new release.

machty commented 1 year ago

This has been working well for us on production for a few months now -- any chance we could this merged?

alecdotninja commented 1 year ago

Thanks for the bump. I totally forgot about this PR.

alecdotninja commented 1 year ago

@machty Thank you for your work on this! This is now released as v1.5.0.