Class: ActiveRecord::ConnectionAdapters::MSSQL::TableDefinition

Inherits:
TableDefinition
  • Object
show all
Includes:
ColumnMethods
Defined in:
lib/arjdbc/mssql/schema_definitions.rb

Instance Method Summary collapse

Methods included from ColumnMethods

#binary_basic, #char, #datetime_basic, #json, #money, #nchar, #ntext, #primary_key, #real, #smalldatetime, #smallmoney, #text_basic, #uuid, #varbinary, #varchar, #varchar_max

Instance Method Details

#column(name, type, index: nil, **options) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/arjdbc/mssql/schema_definitions.rb', line 82

def column(name, type, index: nil, **options)
  # TODO: remove this when the below changed is released
  #   Fix erroneous nil default precision on virtual datetime columns #46110
  #   https://github.com/rails/rails/pull/46110
  #
  if @conn.supports_datetime_with_precision?
    if type == :datetime && !options.key?(:precision)
      options[:precision] = 7
    end
  end

  super
end

#new_column_definition(name, type, **options) ⇒ Object



97
98
99
100
101
102
103
104
105
106
# File 'lib/arjdbc/mssql/schema_definitions.rb', line 97

def new_column_definition(name, type, **options)
  case type
  when :primary_key
    options[:is_identity] = true
  when :datetime
    options[:precision] = 7 if !options.key?(:precision) && @conn.supports_datetime_with_precision?
  end

  super
end

#timestamps(**options) ⇒ Object



108
109
110
111
112
# File 'lib/arjdbc/mssql/schema_definitions.rb', line 108

def timestamps(**options)
  options[:precision] = 7 if !options.key?(:precision) && @conn.supports_datetime_with_precision?

  super
end