Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
fixing contains option when working with fields
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronLasseigne committed Apr 16, 2012
1 parent cdc5471 commit 382166b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.md
@@ -1,2 +1,5 @@
## 0.1.1
* fix for contains option

## 0.1.0
* initial release
4 changes: 2 additions & 2 deletions lib/with_filters/active_record_model_extension.rb
Expand Up @@ -79,7 +79,7 @@ def to_a
end

field_options = {}
field_options = options[:fields][field] if options[:fields] and options[:fields][field]
field_options = options[:fields][field.to_sym] if options[:fields] and options[:fields][field.to_sym]

if field_options.is_a?(Proc)
relation = field_options.call(value, relation)
Expand All @@ -100,7 +100,7 @@ def to_a
when :Array
relation.where([Array.new(value.size, "#{quoted_field} LIKE ?").join(' OR '), *value])
when :Hash
if ![:datetime, :timestamp].include?(relation.with_filters_data[:column_types][field]) or Date._parse(value[:start])[:sec_fraction]
if ![:datetime, :timestamp].include?(relation.with_filters_data[:column_types][field.to_sym]) or Date._parse(value[:start])[:sec_fraction]
relation.where(["#{quoted_field} BETWEEN :start AND :stop", value])
else
relation.where(["#{quoted_field} >= :start AND #{quoted_field} < :stop", value])
Expand Down
2 changes: 1 addition & 1 deletion lib/with_filters/version.rb
@@ -1,3 +1,3 @@
module WithFilters
VERSION = '0.1.0'
VERSION = '0.1.1'
end

0 comments on commit 382166b

Please sign in to comment.