Sha256: 4c2da431b2c84118abf8b2126f6fc4a138ebe7ecef42fc92b19d180536c49655
Contents?: true
Size: 1.69 KB
Versions: 5
Compression:
Stored size: 1.69 KB
Contents
module ActiveRecord module ConnectionAdapters module SQLServer module Type class Time < ActiveRecord::Type::Time include TimeValueFractional2 def serialize(value) value = super return value unless value.acts_like?(:time) time = value.to_s(:_sqlserver_time).tap do |v| fraction = quote_fractional(value) v << ".#{fraction}" end Data.new time, self end if defined? JRUBY_VERSION # Currently only called from our custom Time type for formatting def _formatted(value) "#{value.to_s(:_sqlserver_time)}.#{quote_fractional(value)}" end # @Override # We do not want the Time object to be turned into a string def serialize(value) value = super value.acts_like?(:time) ? CoreExt::Time._at_with_sql_type(value, self) : value end end def deserialize(value) value.is_a?(Data) ? super(value.value) : super end def type_cast_for_schema(value) serialize(value).quoted end def sqlserver_type "time(#{precision.to_i})" end def quoted(value) Utils.quote_string_single(value) end private def cast_value(value) value = super return if value.blank? value = value.change year: 2000, month: 01, day: 01 apply_seconds_precision(value) end def fractional_scale precision end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems