All Projects → alecdotninja → active_record_distinct_on

alecdotninja / active_record_distinct_on

Licence: MIT license
Support for `DISTINCT ON` statements when querying with ActiveRecord

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to active record distinct on

activerecord-setops
Union, Intersect, and Difference set operations for ActiveRecord (also, SQL's UnionAll).
Stars: ✭ 21 (-8.7%)
Mutual labels:  activerecord, arel
wharel
Arel made simple
Stars: ✭ 95 (+313.04%)
Mutual labels:  activerecord, arel
database cleaner-active record
Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing.
Stars: ✭ 35 (+52.17%)
Mutual labels:  activerecord
activerecord-cockroachdb-adapter
CockroachDB adapter for ActiveRecord.
Stars: ✭ 90 (+291.3%)
Mutual labels:  activerecord
paper trail-association tracking
Plugin for the PaperTrail gem to track and reify associations
Stars: ✭ 103 (+347.83%)
Mutual labels:  activerecord
alloy
Patchwork now rename to [alloy], alloy is a simple toolkit that makes your iOS / OS X apps development more easier.
Stars: ✭ 61 (+165.22%)
Mutual labels:  activerecord
nxt state machine
A simple but powerful state machine implementation.
Stars: ✭ 14 (-39.13%)
Mutual labels:  activerecord
ebisu connection
EbisuConnection allows access to replica servers
Stars: ✭ 14 (-39.13%)
Mutual labels:  activerecord
activeentity
Active Record without Database
Stars: ✭ 46 (+100%)
Mutual labels:  activerecord
sinatras-skeleton
Basic Sinatra Skeleton MVC CRUD App with Sprockets, Warden, ActiveRecord and PostgresQL
Stars: ✭ 13 (-43.48%)
Mutual labels:  activerecord
sinatra-api-server-toolbox
Sinatra API Server Toolbox (Ruby, Sinatra, ActiveRecord, postgreSQL, JSON, jQuery, AJAX)
Stars: ✭ 21 (-8.7%)
Mutual labels:  activerecord
Neo
Orm框架:基于ActiveRecord思想开发的至简化的java的Orm框架
Stars: ✭ 35 (+52.17%)
Mutual labels:  activerecord
php-orm-benchmark
The benchmark to compare performance of PHP ORM solutions.
Stars: ✭ 82 (+256.52%)
Mutual labels:  activerecord
index shotgun
duplicate index checker 🔥 🔫 👮
Stars: ✭ 35 (+52.17%)
Mutual labels:  activerecord
activerecord-mysql2rgeo-adapter
ActiveRecord connection adapter for gis, based on mysql and rgeo
Stars: ✭ 25 (+8.7%)
Mutual labels:  activerecord
scopy
Common ActiveRecord scopes as model concerns
Stars: ✭ 13 (-43.48%)
Mutual labels:  activerecord
duck record
Used for creating virtual models like ActiveType or ModelAttribute does.
Stars: ✭ 23 (+0%)
Mutual labels:  activerecord
prefixed ids
Friendly Prefixed IDs for your Ruby on Rails models
Stars: ✭ 159 (+591.3%)
Mutual labels:  activerecord
siphon
Siphon enables you to easily combine your scopes with params
Stars: ✭ 23 (+0%)
Mutual labels:  activerecord
squint
Search PostgreSQL jsonb and hstore columns
Stars: ✭ 26 (+13.04%)
Mutual labels:  activerecord

ActiveRecordDistinctOn

Gem Version Build Status Code Climate Test Coverage Security

ActiveRecordDistinctOn 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 adds support for Arel::Nodes::DistinctOn in the future, it should work seamlessly.

Installation

Add this line to your application's Gemfile:

gem 'active_record_distinct_on'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_record_distinct_on

Usage

This gem defines ActiveRecord::Base.distinct_on and ActiveRecord::Relation#distinct_on. Both accept a variable number of column arguments.

For example:

Dog.distinct_on(:name, :owner_id)

Generates SQL like:

SELECT DISTINCT ON ( "dogs"."name", "dogs.owner_id" ) "dogs".* FROM "dogs"

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.

Development

The development dependencies of this gem are managed using Bundler.

After 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.

To 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.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].