class Mkxms::Mssql::TableType::Column

Constants

SQL_OBJECT_TYPE

Attributes

capacity[RW]
collation[RW]
computed_expression[RW]
name[RW]
precision[RW]
scale[RW]
type_name[RW]
type_schema[RW]
xml_schema_collection[RW]

Public Class Methods

new(attrs) click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 14
def initialize(attrs)
  a = attrs
  @name = a['name']
  @type_schema = a['type-schema']
  @type_name = a['type']
  @capacity = a['capacity']
  @capacity = @capacity.to_i unless @capacity.nil? || @capacity == 'max'
  @precision = a['precision']
  @scale = a['scale']
  @collation = a['collation']
  @nullable = !!a['nullable']
  @ansi_padded = !a['not-ansi-padded']
  @full_xml_document = !!a['full-xml-document']
  @xml_schema_collection = a['xml_collection_id']
end

Public Instance Methods

ansi_padded=(val) click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 38
def ansi_padded=(val); @ansi_padded = !!val; end
ansi_padded?() click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 37
def ansi_padded?; @ansi_padded; end
full_xml_document=(val) click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 41
def full_xml_document=(val); @full_xml_document = !!val; end
full_xml_document?() click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 40
def full_xml_document?; @full_xml_document; end
max_byte_consumption() click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 55
def max_byte_consumption
  if [nil, '[sys]'].include?(type_schema) && %w[[nchar] [nvarchar]].include?(type_name)
    2 * capacity
  else
    capacity
  end
end
nullable=(val) click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 35
def nullable=(val); @nullable = !!val; end
nullable?() click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 34
def nullable?; @nullable; end
type_spec() click to toggle source
# File lib/mkxms/mssql/table_type_handler.rb, line 43
def type_spec
  [type_schema, type_name].compact.join('.').tap do |result|
    result << "(#{capacity})" if capacity
    result << " COLLATE #{collation}" if collation
    result << "(#{[precision, scale].compact.join(', ')})" if precision
    result << ' NOT NULL' unless nullable?
    check_constraints.each do |c|
      result << " #{c.to_sql}"
    end
  end
end