Class: Mkxms::Mssql::TableType::Column
- Inherits:
-
Object
- Object
- Mkxms::Mssql::TableType::Column
- Extended by:
- Utils::InitializedAttributes
- Includes:
- ExtendedProperties
- Defined in:
- lib/mkxms/mssql/table_type_handler.rb
Constant Summary collapse
- SQL_OBJECT_TYPE =
'COLUMN'
Instance Attribute Summary collapse
-
#capacity ⇒ Object
Returns the value of attribute capacity.
-
#collation ⇒ Object
Returns the value of attribute collation.
-
#computed_expression ⇒ Object
Returns the value of attribute computed_expression.
-
#name ⇒ Object
Returns the value of attribute name.
-
#precision ⇒ Object
Returns the value of attribute precision.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#type_name ⇒ Object
Returns the value of attribute type_name.
-
#type_schema ⇒ Object
Returns the value of attribute type_schema.
-
#xml_schema_collection ⇒ Object
Returns the value of attribute xml_schema_collection.
Instance Method Summary collapse
- #ansi_padded=(val) ⇒ Object
- #ansi_padded? ⇒ Boolean
- #full_xml_document=(val) ⇒ Object
- #full_xml_document? ⇒ Boolean
-
#initialize(attrs) ⇒ Column
constructor
A new instance of Column.
- #max_byte_consumption ⇒ Object
- #nullable=(val) ⇒ Object
- #nullable? ⇒ Boolean
- #type_spec ⇒ Object
Methods included from Utils::InitializedAttributes
Methods included from ExtendedProperties
Constructor Details
#initialize(attrs) ⇒ Column
Returns a new instance of Column.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 |
Instance Attribute Details
#capacity ⇒ Object
Returns the value of attribute capacity.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def capacity @capacity end |
#collation ⇒ Object
Returns the value of attribute collation.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def collation @collation end |
#computed_expression ⇒ Object
Returns the value of attribute computed_expression.
31 32 33 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 31 def computed_expression @computed_expression end |
#name ⇒ Object
Returns the value of attribute name.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def name @name end |
#precision ⇒ Object
Returns the value of attribute precision.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def precision @precision end |
#scale ⇒ Object
Returns the value of attribute scale.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def scale @scale end |
#type_name ⇒ Object
Returns the value of attribute type_name.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def type_name @type_name end |
#type_schema ⇒ Object
Returns the value of attribute type_schema.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def type_schema @type_schema end |
#xml_schema_collection ⇒ Object
Returns the value of attribute xml_schema_collection.
30 31 32 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 30 def xml_schema_collection @xml_schema_collection end |
Instance Method Details
#ansi_padded=(val) ⇒ Object
38 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 38 def ansi_padded=(val); @ansi_padded = !!val; end |
#ansi_padded? ⇒ Boolean
37 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 37 def ansi_padded?; @ansi_padded; end |
#full_xml_document=(val) ⇒ Object
41 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 41 def full_xml_document=(val); @full_xml_document = !!val; end |
#full_xml_document? ⇒ Boolean
40 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 40 def full_xml_document?; @full_xml_document; end |
#max_byte_consumption ⇒ Object
55 56 57 58 59 60 61 |
# 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) ⇒ Object
35 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 35 def nullable=(val); @nullable = !!val; end |
#nullable? ⇒ Boolean
34 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 34 def nullable?; @nullable; end |
#type_spec ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# 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 |