Class: Mkxms::Mssql::TableType::KeyConstraint
- Inherits:
-
Object
- Object
- Mkxms::Mssql::TableType::KeyConstraint
- Extended by:
- Utils::InitializedAttributes
- Includes:
- ExtendedProperties
- Defined in:
- lib/mkxms/mssql/table_type_handler.rb
Constant Summary collapse
- SQL_OBJECT_TYPE =
'CONSTRAINT'
Instance Attribute Summary collapse
-
#ignore_duplicates ⇒ Object
Returns the value of attribute ignore_duplicates.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #clustered=(val) ⇒ Object
- #clustered? ⇒ Boolean
- #ignore_duplicates? ⇒ Boolean
-
#initialize(attrs) ⇒ KeyConstraint
constructor
A new instance of KeyConstraint.
- #to_sql ⇒ Object
Methods included from Utils::InitializedAttributes
Methods included from ExtendedProperties
Constructor Details
#initialize(attrs) ⇒ KeyConstraint
Returns a new instance of KeyConstraint.
88 89 90 91 92 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 88 def initialize(attrs) @type = attrs['type'] @clustered = !!attrs['clustered'] @ignore_duplicates = !!attrs['ignore-duplicates'] end |
Instance Attribute Details
#ignore_duplicates ⇒ Object
Returns the value of attribute ignore_duplicates.
94 95 96 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 94 def ignore_duplicates @ignore_duplicates end |
#type ⇒ Object
Returns the value of attribute type.
94 95 96 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 94 def type @type end |
Instance Method Details
#clustered=(val) ⇒ Object
98 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 98 def clustered=(val); @clustered = !!val; end |
#clustered? ⇒ Boolean
97 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 97 def clustered?; @clustered; end |
#ignore_duplicates? ⇒ Boolean
100 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 100 def ignore_duplicates?; @ignore_duplicates; end |
#to_sql ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/mkxms/mssql/table_type_handler.rb', line 103 def to_sql "#{type} #{clustered? ? "CLUSTERED" : "NONCLUSTERED"} (#{ columns.map(&:spec).join(', ') })".tap do |result| result << " WITH (IGNORE_DUP_KEY = ON)" if ignore_duplicates? end end |