diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-01 04:33:56 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-01 04:33:56 +0530 |
commit | 8a32d3796778fc1f151a2259fa3b32b9d3c8d56b (patch) | |
tree | 895cfeb457240375ff60e9bb71bd1cffe05e1bcc /activerecord/lib/active_record/relation | |
parent | c62e88a5ab7bc0a70e36dceda2a0f22995a5d087 (diff) | |
download | rails-8a32d3796778fc1f151a2259fa3b32b9d3c8d56b.tar.gz rails-8a32d3796778fc1f151a2259fa3b32b9d3c8d56b.tar.bz2 rails-8a32d3796778fc1f151a2259fa3b32b9d3c8d56b.zip |
Handle Range with excluded end
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 08840d102a..d5e0c90184 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -23,8 +23,15 @@ module ActiveRecord attribute = arel_table[column] || Arel::Attribute.new(arel_table, column.to_sym) case value - when Array, Range, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope + when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope attribute.in(value) + when Range + # TODO : Arel should handle ranges with excluded end. + if value.exclude_end? + [attribute.gteq(value.begin), attribute.lt(value.end)] + else + attribute.in(value) + end else attribute.eq(value) end |