# File lib/jdbc_adapter/jdbc_mssql.rb, line 92 def cast_to_datetime(value) if value.is_a?(Time) if value.year != 0 and value.month != 0 and value.day != 0 return value else return Time.mktime(2000, 1, 1, value.hour, value.min, value.sec) rescue nil end end return cast_to_time(value) if value.is_a?(Date) or value.is_a?(String) rescue nil value end
# File lib/jdbc_adapter/jdbc_mssql.rb, line 83 def cast_to_time(value) return value if value.is_a?(Time) time_array = ParseDate.parsedate(value) time_array[0] ||= 2000 time_array[1] ||= 1 time_array[2] ||= 1 Time.send(ActiveRecord::Base.default_timezone, *time_array) rescue nil end
# File lib/jdbc_adapter/jdbc_mssql.rb, line 41 def simplified_type(field_type) case field_type when /int|bigint|smallint|tinyint/ then :integer when /numeric/ then (@scale.nil? || @scale == 0) ? :integer : :decimal when /float|double|decimal|money|real|smallmoney/ then :decimal when /datetime|smalldatetime/ then :datetime when /timestamp/ then :timestamp when /time/ then :time when /text|ntext/ then :text when /binary|image|varbinary/ then :binary when /char|nchar|nvarchar|string|varchar/ then :string when /bit/ then :boolean when /uniqueidentifier/ then :string end end
# File lib/jdbc_adapter/jdbc_mssql.rb, line 57 def type_cast(value) return nil if value.nil? || value == "(null)" || value == "(NULL)" case type when :string then unquote_string value when :integer then unquote(value).to_i rescue value ? 1 : 0 when :primary_key then value == true || value == false ? value == true ? 1 : 0 : value.to_i when :decimal then self.class.value_to_decimal(unquote(value)) when :datetime then cast_to_datetime(value) when :timestamp then cast_to_time(value) when :time then cast_to_time(value) when :date then cast_to_datetime(value) when :boolean then value == true or (value =~ /^t(rue)?$/) == 0 or unquote(value)=="1" when :binary then unquote value else value end end
Generated with the Darkfish Rdoc Generator 2.