Permalink
Browse files

Allow direct facet comparison for non-string, non-nil values

  • Loading branch information...
1 parent 15774b8 commit b704446a0a6b66a2179bf01bd0851a2965c5ad87 @pat pat committed Sep 6, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/thinking_sphinx/facet.rb
@@ -104,7 +104,14 @@ def translate(object, attribute_value)
method = value_source || column.__name
object = objects.one? ? objects.first : objects.detect { |item|
result = item.send(method)
- result && result.to_crc32 == attribute_value
+ case result
+ when String
+ result.to_crc32 == attribute_value
+ when NilClass
+ false
+ else
+ result == attribute_value
+ end
}
object ? object.send(method) : nil

0 comments on commit b704446

Please sign in to comment.