lib/thinking_sphinx/attribute.rb in warp-thinking-sphinx-1.2.12 vs lib/thinking_sphinx/attribute.rb in warp-thinking-sphinx-1.3.10
- old
+ new
@@ -99,18 +99,18 @@
when :string
adapter.convert_nulls(part)
when :datetime
adapter.cast_to_datetime(part)
when :multi
- part = adapter.cast_to_datetime(part) if is_many_datetimes?
- adapter.convert_nulls(part, 0)
+ part = adapter.cast_to_datetime(part) if is_many_datetimes?
+ part = adapter.convert_nulls(part, '0') if is_many_ints?
+ part
else
part
end
}.join(', ')
- # clause = adapter.cast_to_datetime(clause) if type == :datetime
clause = adapter.crc(clause) if @crc
clause = adapter.concatenate(clause, separator) if concat_ws?
"#{clause} AS #{quote_column(unique_name)}"
end
@@ -177,11 +177,11 @@
def live_value(instance)
object = instance
column = @columns.first
column.__stack.each { |method| object = object.send(method) }
- object.send(column.__name)
+ sphinx_value object.send(column.__name)
end
def all_ints?
all_of_type?(:integer)
end
@@ -333,8 +333,23 @@
klasses.all? { |klass|
column = klass.columns.detect { |column| column.name == col.__name.to_s }
!column.nil? && column_types.include?(column.type)
}
}
+ end
+
+ def sphinx_value(value)
+ case value
+ when TrueClass
+ 1
+ when FalseClass, NilClass
+ 0
+ when Time
+ value.to_i
+ when Date
+ value.to_time.to_i
+ else
+ value
+ end
end
end
end