Skip to content

jmchilton/aliased_sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aliased_sql -- Adds to_aliased_sql method to active record relations

Active record relations have a to_sql method that converts relations into SQL select expressions. These expressions however reference the table specified in the SELECT expression's FROM clause by the acutal table name. The upshot of this is that it can be difficult to compose multiple SQL expressions created this way if they reference the same table.

I make no pretense that building up SQL expressions this way is a good idea and it certainly is not a very Railsy way of doing things. But for weak rails developers like myself, this gem adds the ability to build an SQL expression that specifies an alias in the FROM clause and references the table via this throughout the rest of the expression.

Install

First add the following line to your Rails Gemfile.

gem 'aliased_sql', :git => 'git://github.com/jmchilton/aliased_sql.git'

Then simply run bundle.

Usage

Simply require 'aliased_sql' and then use the to_aliased_sql method. See the spec for more details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages