Sha256: 5ed06260fa0acbebbaf1521a3921e87ba5ec42188779674b12a07a84361d6da0
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
= Inequal Opportunity ActiveRecord is a ruby ORM released with Ruby on Rails. It has a hash syntax for specifying SQL conditions: YourModel.count(:conditions => {:id => 5}) YourModel.all(:limit => 5, :order => :created_at, :conditions => {:user_id => 5}) But this hash format lacks inequalities. In order to generate: SELECT * from your_models where id <> '42'; You have to write: YourModel.count(:conditions => ['id <> ?', 42]) With Inequal Opportunity, you can write: YourModel.count(:conditions => {:id => ne(42)}) Where Object#ne wraps 42 in a ActiveRecord::Inequality::NotEqual class, which is then used to insert the proper operator into the generated SQL. Other supported inequalities are: gte() => >= gt() => > lte() => <= le() => < ne() => <> ne(nil) => IS NOT Test coverage is real sparse right now. And it's only been tested on MySQL. I also am not completely satisfied with the way I overwrite ActiveRecord.expand_range_bind_variables, but it works. == License Inequal Opportunity is released under the MIT license. == Support Just email me at ryan@angilly.com with questions, bugs, or patches
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ryana-inequal_opportunity-0.1.2 | README |