Class: Mkxms::Mssql::DefaultConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/mkxms/mssql/default_constraint_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema, table, column, name) ⇒ DefaultConstraint

Returns a new instance of DefaultConstraint.



5
6
7
8
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 5

def initialize(schema, table, column, name)
  @schema, @table, @column, @name = schema, table, column, name
  @expression = ''
end

Instance Attribute Details

#columnObject

Returns the value of attribute column.



10
11
12
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 10

def column
  @column
end

#expressionObject

Returns the value of attribute expression.



10
11
12
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 10

def expression
  @expression
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 10

def name
  @name
end

#schemaObject

Returns the value of attribute schema.



10
11
12
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 10

def schema
  @schema
end

#tableObject

Returns the value of attribute table.



10
11
12
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 10

def table
  @table
end

Instance Method Details

#qualified_columnObject



20
21
22
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 20

def qualified_column
  "#@schema.#@table.#@column"
end

#qualified_nameObject



24
25
26
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 24

def qualified_name
  "#@schema.#@name" if @name
end

#qualified_tableObject



16
17
18
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 16

def qualified_table
  "#@schema.#@table"
end

#to_sqlObject



12
13
14
# File 'lib/mkxms/mssql/default_constraint_handler.rb', line 12

def to_sql
  "ALTER TABLE #@schema.#@table ADD #{"CONSTRAINT #@name" if @name} DEFAULT #@expression FOR #@column;"
end