Skip to content

Commit

Permalink
Default to proper string attributes if using Sphinx 2.0.x.
Browse files Browse the repository at this point in the history
Filtering doesn't work, but it didn't with the str2ordinal attributes either - sorting works fine.
  • Loading branch information
pat committed May 24, 2011
1 parent 40aff14 commit a548361
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/thinking_sphinx/attribute.rb
Expand Up @@ -11,6 +11,21 @@ module ThinkingSphinx
class Attribute < ThinkingSphinx::Property
attr_accessor :query_source

SphinxTypeMappings = {
:multi => :sql_attr_multi,
:datetime => :sql_attr_timestamp,
:string => :sql_attr_str2ordinal,
:float => :sql_attr_float,
:boolean => :sql_attr_bool,
:integer => :sql_attr_uint,
:bigint => :sql_attr_bigint,
:wordcount => :sql_attr_str2wordcount
}

if Riddle.loaded_version.to_i > 1
SphinxTypeMappings[:string] = :sql_attr_string
end

# To create a new attribute, you'll need to pass in either a single Column
# or an array of them, and some (optional) options.
#
Expand Down Expand Up @@ -117,16 +132,7 @@ def to_select_sql
end

def type_to_config
{
:multi => :sql_attr_multi,
:datetime => :sql_attr_timestamp,
:string => :sql_attr_str2ordinal,
:float => :sql_attr_float,
:boolean => :sql_attr_bool,
:integer => :sql_attr_uint,
:bigint => :sql_attr_bigint,
:wordcount => :sql_attr_str2wordcount
}[type]
SphinxTypeMappings[type]
end

def include_as_association?
Expand Down

0 comments on commit a548361

Please sign in to comment.