Module: ActiveRecord::ConnectionAdapters::SQLServer::ColumnMethods

Included in:
Table, TableDefinition
Defined in:
lib/active_record/connection_adapters/sqlserver/table_definition.rb

Instance Method Summary collapse

Instance Method Details

#binary_basic(*names, **options) ⇒ Object



78
79
80
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 78

def binary_basic(*names, **options)
  names.each { |name| column(name, :binary_basic, **options) }
end

#char(*names, **options) ⇒ Object



54
55
56
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 54

def char(*names, **options)
  names.each { |name| column(name, :char, **options) }
end

#datetime(*names, **options) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 32

def datetime(*names, **options)
  names.each do |name|
    if options[:precision]
      datetime2(name, **options)
    else
      column(name, :datetime, **options)
    end
  end
end

#datetime2(*names, **options) ⇒ Object



42
43
44
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 42

def datetime2(*names, **options)
  names.each { |name| column(name, :datetime2, **options) }
end

#datetimeoffset(*names, **options) ⇒ Object



46
47
48
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 46

def datetimeoffset(*names, **options)
  names.each { |name| column(name, :datetimeoffset, **options) }
end

#json(*names, **options) ⇒ Object



94
95
96
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 94

def json(*names, **options)
  names.each { |name| column(name, :text, **options) }
end

#money(*names, **options) ⇒ Object



24
25
26
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 24

def money(*names, **options)
  names.each { |name| column(name, :money, **options) }
end

#nchar(*names, **options) ⇒ Object



70
71
72
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 70

def nchar(*names, **options)
  names.each { |name| column(name, :nchar, **options) }
end

#ntext(*names, **options) ⇒ Object



74
75
76
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 74

def ntext(*names, **options)
  names.each { |name| column(name, :ntext, **options) }
end

#primary_key(name, type = :primary_key, **options) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 7

def primary_key(name, type = :primary_key, **options)
  if [:integer, :bigint].include?(type)
    options[:is_identity] = true unless options.key?(:default)
  elsif type == :uuid
    options[:default] = options.fetch(:default, "NEWID()")
  end
  super
end

#primary_key_nonclustered(*names, **options) ⇒ Object



16
17
18
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 16

def primary_key_nonclustered(*names, **options)
  names.each { |name| column(name, :primary_key_nonclustered, **options) }
end

#real(*names, **options) ⇒ Object



20
21
22
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 20

def real(*names, **options)
  names.each { |name| column(name, :real, **options) }
end

#smalldatetime(*names, **options) ⇒ Object



28
29
30
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 28

def smalldatetime(*names, **options)
  names.each { |name| column(name, :smalldatetime, **options) }
end

#smallmoney(*names, **options) ⇒ Object



50
51
52
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 50

def smallmoney(*names, **options)
  names.each { |name| column(name, :smallmoney, **options) }
end

#ss_timestamp(*names, **options) ⇒ Object



90
91
92
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 90

def ss_timestamp(*names, **options)
  names.each { |name| column(name, :ss_timestamp, **options) }
end

#text_basic(*names, **options) ⇒ Object



66
67
68
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 66

def text_basic(*names, **options)
  names.each { |name| column(name, :text_basic, **options) }
end

#uuid(*names, **options) ⇒ Object



86
87
88
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 86

def uuid(*names, **options)
  names.each { |name| column(name, :uniqueidentifier, **options) }
end

#varbinary(*names, **options) ⇒ Object



82
83
84
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 82

def varbinary(*names, **options)
  names.each { |name| column(name, :varbinary, **options) }
end

#varchar(*names, **options) ⇒ Object



58
59
60
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 58

def varchar(*names, **options)
  names.each { |name| column(name, :varchar, **options) }
end

#varchar_max(*names, **options) ⇒ Object



62
63
64
# File 'lib/active_record/connection_adapters/sqlserver/table_definition.rb', line 62

def varchar_max(*names, **options)
  names.each { |name| column(name, :varchar_max, **options) }
end