Class: ActiveRecord::ConnectionAdapters::SQLServerColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/sqlserver_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, default, sql_type = nil, null = true, sqlserver_options = {}) ⇒ SQLServerColumn

Returns a new instance of SQLServerColumn.



65
66
67
68
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 65

def initialize(name, default, sql_type = nil, null = true, sqlserver_options = {})
  @sqlserver_options = sqlserver_options.symbolize_keys
  super(name, default, sql_type, null)
end

Class Method Details

.binary_to_string(value) ⇒ Object



76
77
78
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 76

def binary_to_string(value)
  value =~ /[^[:xdigit:]]/ ? value : [value].pack('H*')
end

.string_to_binary(value) ⇒ Object



72
73
74
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 72

def string_to_binary(value)
 "0x#{value.unpack("H*")[0]}"
end

Instance Method Details

#database_yearObject



107
108
109
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 107

def database_year
  @sqlserver_options[:database_year]
end

#default_functionObject



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

def default_function
  @sqlserver_options[:default_function]
end

#is_identity?Boolean

Returns:

  • (Boolean)


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

def is_identity?
  @sqlserver_options[:is_identity]
end

#is_utf8?Boolean

Returns:

  • (Boolean)


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

def is_utf8?
  @sql_type =~ /nvarchar|ntext|nchar/i
end

#table_klassObject



98
99
100
101
102
103
104
105
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 98

def table_klass
  @table_klass ||= begin
    table_name.classify.constantize
  rescue StandardError, NameError, LoadError
    nil
  end
  (@table_klass && @table_klass < ActiveRecord::Base) ? @table_klass : nil
end

#table_nameObject



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

def table_name
  @sqlserver_options[:table_name]
end