{"id":14446734,"url":"https://github.com/alecdotninja/active_record_distinct_on","last_synced_at":"2025-04-04T18:07:02.244Z","repository":{"id":10636113,"uuid":"66436157","full_name":"alecdotninja/active_record_distinct_on","owner":"alecdotninja","description":"Support for `DISTINCT ON` statements when querying with ActiveRecord","archived":false,"fork":false,"pushed_at":"2024-12-14T22:31:47.000Z","size":74,"stargazers_count":34,"open_issues_count":2,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T06:44:27.332Z","etag":null,"topics":["activerecord","arel","database","rails","ruby","sql"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alecdotninja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-24T06:21:37.000Z","updated_at":"2024-12-14T22:31:51.000Z","dependencies_parsed_at":"2025-02-15T14:13:06.230Z","dependency_job_id":"b317c2ea-7355-4bd2-825a-673bc63be2c5","html_url":"https://github.com/alecdotninja/active_record_distinct_on","commit_stats":{"total_commits":45,"total_committers":11,"mean_commits":4.090909090909091,"dds":0.7333333333333334,"last_synced_commit":"cda1faa752c9ab0c372bf0db3616f7f6fbaaa1ea"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecdotninja%2Factive_record_distinct_on","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecdotninja%2Factive_record_distinct_on/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecdotninja%2Factive_record_distinct_on/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecdotninja%2Factive_record_distinct_on/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecdotninja","download_url":"https://codeload.github.com/alecdotninja/active_record_distinct_on/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","arel","database","rails","ruby","sql"],"created_at":"2024-09-01T07:01:05.479Z","updated_at":"2025-04-04T18:07:02.227Z","avatar_url":"https://github.com/alecdotninja.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ActiveRecordDistinctOn\n\n[![Gem Version](https://badge.fury.io/rb/active_record_distinct_on.svg)](https://badge.fury.io/rb/active_record_distinct_on)\n![Build Status](https://github.com/alecdotninja/active_record_distinct_on/actions/workflows/test.yml/badge.svg)\n[![Code Climate](https://codeclimate.com/github/alecdotninja/active_record_distinct_on/badges/gpa.svg)](https://codeclimate.com/github/alecdotninja/active_record_distinct_on)\n[![Test Coverage](https://codeclimate.com/github/alecdotninja/active_record_distinct_on/badges/coverage.svg)](https://codeclimate.com/github/alecdotninja/active_record_distinct_on/coverage)\n[![Security](https://hakiri.io/github/alecdotninja/active_record_distinct_on/master.svg)](https://hakiri.io/github/alecdotninja/active_record_distinct_on/master)\n\nActiveRecordDistinctOn adds support for `DISTINCT ON` queries to ActiveRecord. At the time of this writing, PostgreSQL is the only database which supports this syntax; however, this gem has been written with database independence in mind so that if [another Arel visitor](https://github.com/rails/arel/tree/master/lib/arel/visitors) adds support for [`Arel::Nodes::DistinctOn`](https://github.com/rails/arel/blob/master/lib/arel/nodes/unary.rb) in the future, it should work seamlessly.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_record_distinct_on'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install active_record_distinct_on\n\n## Usage\n\nThis gem defines `ActiveRecord::Base.distinct_on` and `ActiveRecord::Relation#distinct_on`. Both accept a variable number of column arguments.\n\nFor example:\n\n```ruby\nDog.distinct_on(:name, :owner_id)\n```\n\nGenerates SQL like:\n\n```sql\nSELECT DISTINCT ON ( \"dogs\".\"name\", \"dogs.owner_id\" ) \"dogs\".* FROM \"dogs\"\n```\n\n**Note:** For applications using ActiveRecord à la carte (without the `rails` gem), none of the methods above will be defined until `ActiveRecordDistinctOn.install` is manually called.\n\n## Development\n\nThe development dependencies of this gem are managed using [Bundler](https://rubygems.org/gems/bundler).\n\nAfter checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rake test:all` to run the tests. You can also run `bundle exec rake console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [RubyGems](https://rubygems.org/gems/active_record_distinct_on).\n\n## Contributing\n\nBug reports and pull requests are welcome on [GitHub](https://github.com/alecdotninja/active_record_distinct_on).\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecdotninja%2Factive_record_distinct_on","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecdotninja%2Factive_record_distinct_on","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecdotninja%2Factive_record_distinct_on/lists"}