alecdotninja / active_record_distinct_on

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

How is this gem different than what's offered in the Rails API? #21

Closed machty closed 1 year ago

machty commented 2 years ago

I'm a bit confused how the Rails API has an Arel Visitor or DISTINCT ON, and that distinct appears to accept a set of columns to perform a DISTINCT ON operation (but in my own tests it doesn't seem to actually cause a DISTINCT ON query to be made)... if these APIs are present in Rails, why don't they work all the way? Also, have you considered putting in a PR against Rails proper? It seems like this functionality should just exist in Rails.

alecdotninja commented 2 years ago

I have not attempted a PR myself, but if I recall correctly from an issue discussion long ago, it comes down to database agnosticism: DISTINCT ON is a Postgres-specific feature and a design goal of ActiveRecord is to abstract those kinds of details away.

I don't actively use this gem anymore, so I don't plan to open an issue or PR against Rails, but if someone else would like to, they are welcome to use the code from this gem.

machty commented 1 year ago

Looks like this is an unmerged PR against rails to merge support for DISTINCT ON: https://github.com/rails/rails/issues/17706

Closing this issue, no further questions your honor.