Class: Mkxms::Mssql::CheckConstraint
- Inherits:
-
Object
- Object
- Mkxms::Mssql::CheckConstraint
- Includes:
- ExtendedProperties, Property::Hosting
- Defined in:
- lib/mkxms/mssql/check_constraint_handler.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#name ⇒ Object
Returns the value of attribute name.
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#table ⇒ Object
Returns the value of attribute table.
-
#when_replicated ⇒ Object
Returns the value of attribute when_replicated.
Instance Method Summary collapse
-
#initialize(schema, table, name, enabled: true, when_replicated: true) ⇒ CheckConstraint
constructor
A new instance of CheckConstraint.
- #property_subject_identifiers ⇒ Object
- #qualified_name ⇒ Object
- #qualified_table ⇒ Object
- #to_sql ⇒ Object
Methods included from ExtendedProperties
Methods included from Property::Hosting
Constructor Details
#initialize(schema, table, name, enabled: true, when_replicated: true) ⇒ CheckConstraint
Returns a new instance of CheckConstraint.
9 10 11 12 13 14 15 16 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 9 def initialize(schema, table, name, enabled: true, when_replicated: true) @schema = schema @table = table @name = name @enabled = enabled @when_replicated = when_replicated @expression = '' end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
18 19 20 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 18 def enabled @enabled end |
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
19 20 21 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 19 def expression @expression end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 18 def name @name end |
#schema ⇒ Object
Returns the value of attribute schema.
18 19 20 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 18 def schema @schema end |
#table ⇒ Object
Returns the value of attribute table.
18 19 20 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 18 def table @table end |
#when_replicated ⇒ Object
Returns the value of attribute when_replicated.
18 19 20 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 18 def when_replicated @when_replicated end |
Instance Method Details
#property_subject_identifiers ⇒ Object
37 38 39 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 37 def property_subject_identifiers ['SCHEMA', schema, 'TABLE', table, 'CONSTRAINT', name].map {|s| Utils::unquoted_name(s)} end |
#qualified_name ⇒ Object
33 34 35 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 33 def qualified_name "#@schema.#@name" if @name end |
#qualified_table ⇒ Object
29 30 31 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 29 def qualified_table "#@schema.#@table" end |
#to_sql ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/mkxms/mssql/check_constraint_handler.rb', line 21 def to_sql "ALTER TABLE #@schema.#@table ADD%s CHECK%s #@expression;%s" % [ @name ? " CONSTRAINT #@name" : '', @when_replicated ? '' : ' NOT FOR REPLICATION', @enabled ? '' : "\nALTER TABLE #@schema.#@table NOCHECK CONSTRAINT #@name;" ] + (name ? extended_properties_sql.joined_on_new_lines : '') end |