Skip to content
Browse files

Handle Range with excluded end

  • Loading branch information...
1 parent c62e88a commit 8a32d3796778fc1f151a2259fa3b32b9d3c8d56b @lifo lifo committed Jan 1, 2010
Showing with 8 additions and 1 deletion.
  1. +8 −1 activerecord/lib/active_record/relation/predicate_builder.rb
View
9 activerecord/lib/active_record/relation/predicate_builder.rb
@@ -23,8 +23,15 @@ def build_from_hash(attributes, default_table)
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

0 comments on commit 8a32d37

Please sign in to comment.
Something went wrong with that request. Please try again.