Class: ActiveRecord::ConnectionAdapters::MSSQL::Type::DateTime

Inherits:
Type::DateTime
  • Object
show all
Defined in:
lib/arjdbc/mssql/types/date_and_time_types.rb

Overview

NOTE: The key here is to get usec in a format like ABC000 to get minimal rounding issues. MSSQL has its own rounding strategy (Rounded to increments of .000, .003, or .007 seconds)

Direct Known Subclasses

SmallDateTime

Instance Method Summary collapse

Instance Method Details

#typeObject



49
50
51
# File 'lib/arjdbc/mssql/types/date_and_time_types.rb', line 49

def type
  :datetime_basic
end

#type_cast_for_schema(value) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/arjdbc/mssql/types/date_and_time_types.rb', line 53

def type_cast_for_schema(value)
  return %("#{value}") if value.acts_like?(:string)

  if value.usec > 0
    %("#{value.to_s(:db)}.#{value.usec.to_s.remove(/0+$/)}")
  else
    %("#{value.to_s(:db)}")
  end
end