Sha256: 6aac6baead3f45605421dd25776a53b75222aa0c8974b0e5fb3fffb6f219a78a
Contents?: true
Size: 1.31 KB
Versions: 27
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true module ActiveRecord module ConnectionAdapters module SQLServer module Type class DateTime < ActiveRecord::Type::DateTime include TimeValueFractional def sqlserver_type "datetime" end def serialize(value) value = super return value unless value.acts_like?(:time) datetime = "#{value.to_formatted_s(:_sqlserver_datetime)}.#{quote_fractional(value)}" Data.new datetime, self end def deserialize(value) value.is_a?(Data) ? super(value.value) : super end def type_cast_for_schema(value) serialize(value).quoted end def quoted(value) Utils.quote_string_single(value) end private def fast_string_to_time(string) time = ActiveSupport::TimeZone["UTC"].strptime(string, fast_string_to_time_format) new_time(time.year, time.month, time.day, time.hour, time.min, time.sec, Rational(time.nsec, 1_000)) rescue ArgumentError super end def fast_string_to_time_format "#{::Time::DATE_FORMATS[:_sqlserver_datetime]}.%N" end end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems