class Mkxms::Mssql::CheckConstraint
Attributes
enabled[RW]
expression[R]
name[RW]
schema[RW]
table[RW]
when_replicated[RW]
Public Class Methods
new(schema, table, name, enabled: true, when_replicated: true)
click to toggle source
# 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
Public Instance Methods
property_subject_identifiers()
click to toggle source
# 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()
click to toggle source
# File lib/mkxms/mssql/check_constraint_handler.rb, line 33 def qualified_name "#@schema.#@name" if @name end
qualified_table()
click to toggle source
# File lib/mkxms/mssql/check_constraint_handler.rb, line 29 def qualified_table "#@schema.#@table" end
to_sql()
click to toggle source
# 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