Class: Mkxms::Mssql::Column
- Inherits:
-
Object
- Object
- Mkxms::Mssql::Column
- Extended by:
- Utils::FlagsQueries
- Includes:
- ExtendedProperties
- Defined in:
- lib/mkxms/mssql/table_handler.rb
Constant Summary collapse
- SQL_OBJECT_TYPE =
'COLUMN'
Instance Attribute Summary collapse
-
#collation ⇒ Object
Returns the value of attribute collation.
-
#computed_expression ⇒ Object
Returns the value of attribute computed_expression.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_info ⇒ Object
readonly
Returns the value of attribute type_info.
Instance Method Summary collapse
- #each_type_part {|type| ... } ⇒ Object
-
#initialize(name) ⇒ Column
constructor
A new instance of Column.
- #to_sql ⇒ Object
Methods included from Utils::FlagsQueries
Methods included from ExtendedProperties
Constructor Details
#initialize(name) ⇒ Column
Returns a new instance of Column.
53 54 55 56 57 |
# File 'lib/mkxms/mssql/table_handler.rb', line 53 def initialize(name) @name = name @flags = [] @type_info = {} end |
Instance Attribute Details
#collation ⇒ Object
Returns the value of attribute collation.
59 60 61 |
# File 'lib/mkxms/mssql/table_handler.rb', line 59 def collation @collation end |
#computed_expression ⇒ Object
Returns the value of attribute computed_expression.
59 60 61 |
# File 'lib/mkxms/mssql/table_handler.rb', line 59 def computed_expression @computed_expression end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
60 61 62 |
# File 'lib/mkxms/mssql/table_handler.rb', line 60 def flags @flags end |
#name ⇒ Object
Returns the value of attribute name.
59 60 61 |
# File 'lib/mkxms/mssql/table_handler.rb', line 59 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
59 60 61 |
# File 'lib/mkxms/mssql/table_handler.rb', line 59 def type @type end |
#type_info ⇒ Object (readonly)
Returns the value of attribute type_info.
60 61 62 |
# File 'lib/mkxms/mssql/table_handler.rb', line 60 def type_info @type_info end |
Instance Method Details
#each_type_part {|type| ... } ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/mkxms/mssql/table_handler.rb', line 76 def each_type_part yield type yield("COLLATE " + collation) if collation yield(nullable? ? 'NULL' : 'NOT NULL') if identity? yield "IDENTITY" yield("NOT FOR REPLICATION") unless replicated? end yield("ROWGUID") if rowguid? end |
#to_sql ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mkxms/mssql/table_handler.rb', line 64 def to_sql parts = [name] if computed_expression parts << "AS " + computed_expression parts << "PERSISTED" if persisted? else each_type_part {|part| parts << part} end return parts.join(' ') end |